Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,059
- Reaction score
- 17,821
Just a few thoughts I'm posting here.
I've pretty much dumped repositories and unit of work. Of the opinion I don't need them anymore and on the hunt for other alternatives.
This is one of them by jerrie pelser. Your DBContext Inteface is resolved in the middleware and then you simply make your _context calls in the services.
There is another take on this with Jason Taylor's clean architecture:
I've pretty much dumped repositories and unit of work. Of the opinion I don't need them anymore and on the hunt for other alternatives.
This is one of them by jerrie pelser. Your DBContext Inteface is resolved in the middleware and then you simply make your _context calls in the services.
C#:
public void ConfigureServices(IServiceCollection services)
{
...
// Add EF services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
// Register the service and implementation for the database context
services.AddScoped<IApplicationDbContext>(provider => provider.GetService<ApplicationDbContext>());
...
}
There is another take on this with Jason Taylor's clean architecture: