EF Core database context abstraction.
- .Net 6
- Entity Framework Core 6
- Autofac 6.x.x
- All entity types that the you wish to access should inherit
EntityManagement.Core.BaseEntity
.- See Team.cs
- Create fluent configurations for each of these data models by inheriting
EntityManagement.BaseEntityConfiguration<TEntity, TId>
for each entity. - Implement database context by inheriting
Microsoft.EntityFrameworkCore.DbContext
(ensure the configurations created in step 2 are added in theOnModelCreating
method). - Create database context design-time factory.
- Call
serices.ConfigureDatabaseContextAndFactory<YouDbContext>(databaseConnectionString)
in theConfigureServices
method of yourStartup
class.- See Startup.cs