public class UnitOfWork : IUnitOfWork
{
private ApplicationDbContext _db;
public ICategoryRepository Category { get; private set; }
public ICoverTypeRepository CoverType { get; private set; }
public IProductRepository Product { get; private set; }
public UnitOfWork(ApplicationDbContext db)
{
_db = db;
Category = new CategoryRepository(_db);
CoverType= new CoverTypeRepository(_db);
Product = new ProductRepository(_db);
}
public void Save()
{
_db.SaveChanges();
}
}
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
public DbSet<Category> Categories { get; set; }
public DbSet<CoverType> CoverTypes { get; set; }
public DbSet<Product> Products { get; set; }
}
System.AggregateException: "Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BulkyBook.DataAccess.Repository.IRepository.IUnitOfWork Lifetime: Singleton ImplementationType: BulkyBook.DataAccess.Repository.UnitOfWork': Unable to resolve service for type 'BulkyBook.DataAccess.ApplicationDbContext' while attempting to activate 'BulkyBook.DataAccess.Repository.UnitOfWork'.)"
ни один не решил проблему