F2.Repository 2025.11.25.750

dotnet add package F2.Repository --version 2025.11.25.750
                    
NuGet\Install-Package F2.Repository -Version 2025.11.25.750
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="F2.Repository" Version="2025.11.25.750" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="F2.Repository" Version="2025.11.25.750" />
                    
Directory.Packages.props
<PackageReference Include="F2.Repository" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add F2.Repository --version 2025.11.25.750
                    
#r "nuget: F2.Repository, 2025.11.25.750"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package F2.Repository@2025.11.25.750
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=F2.Repository&version=2025.11.25.750
                    
Install as a Cake Addin
#tool nuget:?package=F2.Repository&version=2025.11.25.750
                    
Install as a Cake Tool

F2.Repository

Codacy Badge

Simple definitions for repository pattern

Getting started

1. Install Nuget package F2.Repository

Install-Package F2.Repository

2. Implement IEntity<TKey> on your models

Or, you can create your own BaseEntity:

public abstract class BaseEntity : IEntity<Guid>, ITimestampedEntity
{
	public Guid Id { get; set; }
	public DateTime CreatedAt { get; set; }
	public DateTime UpdatedAt { get; set; }
}
public class Book : BaseEntity
{
    public string Title { get; set; }

    public string Isbn { get; set; }

	public virtual ICollection<Author> Authors { get; set; }
}

Create your configuration (see example)

public class BookEntityConfiguration : IEntityTypeConfiguration<Book>
{
	public void Configure(EntityTypeBuilder<Book> builder)
	{
		builder.UseAutoGeneratedId();
		builder.UseTimestampedProperty();

		builder.HasMany(s => s.Authors).WithMany(s => s.Books);
	}
}

3. Implement your repository

GenericEntityRepository<TEntityType> or GenericRepository<TEntityType> abstracts

using F2.Repository.Abstracts;

public class CustomerRepository : GenericEntityRepository<Customer>
{
    public CustomerRepository(YourDbContext context) : base(context)
    {
    }
}

4. Create Database Context Scope

public class YourDbScope : DbContextScope<YourDbContext>
{
    public YourDbScope(YourDbContext context) : base(context)
    {
        YourRepository = yourRepository;
    }

    public YourRepository YourRepository { get; }
}

5. Register Scope and repositories to DI

All repositories will automatically registered for DI

services.AddDatabaseScope<YourDbContext>();
// ... services.AddDbContext<AutomateContext>(opts => opts.UseSqlServer(_configuration.GetConnectionString("SqlConnection"));

Bonus

Add-Migration -Context LibraryContext -Project F2.Repository.Demo PublisherOneToMany
Add-Migration -Context LibraryContext -Project F2.Repository.Demo PublisherOneToManyNullable


Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.11.25.750 539 11/25/2025