Qrtix.RepositoryPattern.EntityFrameworkCore
7.1.0
See the version list below for details.
dotnet add package Qrtix.RepositoryPattern.EntityFrameworkCore --version 7.1.0
NuGet\Install-Package Qrtix.RepositoryPattern.EntityFrameworkCore -Version 7.1.0
<PackageReference Include="Qrtix.RepositoryPattern.EntityFrameworkCore" Version="7.1.0" />
paket add Qrtix.RepositoryPattern.EntityFrameworkCore --version 7.1.0
#r "nuget: Qrtix.RepositoryPattern.EntityFrameworkCore, 7.1.0"
// Install Qrtix.RepositoryPattern.EntityFrameworkCore as a Cake Addin #addin nuget:?package=Qrtix.RepositoryPattern.EntityFrameworkCore&version=7.1.0 // Install Qrtix.RepositoryPattern.EntityFrameworkCore as a Cake Tool #tool nuget:?package=Qrtix.RepositoryPattern.EntityFrameworkCore&version=7.1.0
Repository Pattern implementation for Entity Framework Core
A library for implementing generic repositories and unit of work with Entity Framework Core. This implementation uses a single instance of the DbContext for all repositories to avoid concurrency issues.
Consult the online documentation for more details.
Table of Contents
Installation
Using the NuGet package manager console within Visual Studio run the following command:
Install-Package Ortix.RepositoryPattern.EntityFrameworkCore
Or using the .NET Core CLI from a terminal window:
dotnet add package Qrtix.RepositoryPattern.EntityFrameworkCore
Creating the DbContext
Create your DbContext inheriting from Microsoft.EntityFrameworkCore.DbContext
:
public class MyDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
base.OnModelCreating(modelBuilder);
}
}
Configure your DbContext in the Program
class:
builder.Services.AddDbContext<DbContext, SuinQShopModuleDbContext>(opt =>
{
opt.UseSqlServer(builder.Configuration.GetConnectionString("ConnectionString"));
});
Injecting the RepositoryPattern's Services
Add the RepositoryPattern
services to the Service Collection:
builder.Services.AddRepositoryPattern(options => {
options.UseEntityFrameworkCore();
});
The default scope for injected services is scoped. If you want to change it, refer to the next examples:
Using the same lifetime:
builder.Services.AddRepositoryPattern(options => {
options.UseEntityFrameworCore(ServiceLifetime.Singleton);
});
Using individual lifetime:
builder.Services.AddRepositoryPattern(options => {
options.UseEntityFrameworCore(ServiceLifetime.Scoped, SeriviceLifetime.Singleton);
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.EntityFrameworkCore (>= 7.0.17)
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.17)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Qrtix.RepositoryPattern.Abstractions (>= 7.0.1)
-
net7.0
- Microsoft.EntityFrameworkCore (>= 7.0.17)
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.17)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Qrtix.RepositoryPattern.Abstractions (>= 7.0.1)
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.7)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Qrtix.RepositoryPattern.Abstractions (>= 7.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Added support for including collection navigation properties using the extended
'Then' method, exclusively developed in this library for enhanced this capabilities.