When using Clean Architecture in Mvc Core, Layer with Name can be like this:
- Infrastructure
- Core
- Web
This link has complete description about that:
Principles says that Web project shouldn't have any reference from Infrastructure class library. So how can use a DI container to resolve the problem?
This code in Startup.cs
uses Infrastructure to config some things:
public void ConfigureProductionServices(IServiceCollection services)
{
services.AddDbContext<CatalogContext>(c =>
{
try
{
c.UseSqlServer(Configuration.GetConnectionString("CatalogConnection"));
}
catch (Exception ex)
{
var message = ex.Message;
}
});
services.AddDbContext<AppIdentityDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("CatalogConnection")));
ConfigureServices(services);
}
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AppIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
.
.
_services = services;
}