I have a .net Core 3.1 project, which uses a class library for DAL and a Class library for the BLL layer and a Core 3.1 MVC project.
The DAL project registers the BLL interface with the the DAL class as the implementation type. It uses ADO and not EF.
public static class ServiceCollectionExtensions
{
// Add parameters if required, e.g. for configuration
public static IServiceCollection AddDAL(this IServiceCollection services)
{
// Register all services as required
services.AddScoped<ITenementLeaseBll, TenementLeaseDal>();
return services;
}
}
The "AddDal" is registered in the startup.cs (ConfigureServices(IServiceCollection services) as
services.AddDAL();
Following some posts re this, where I try use
var connection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<AppDBContext>(options => options.UseSqlServer(connection));
I get the error 'IServiceCollection' does not contain a definition for 'AddDbContext'
How do I inject the db connection string , should it be in Startup.cs or should it (can it) be in the DAL project?
TIA