I'm using two context, but now the need to create a RepositoryBase has arisen, but returns this error to me:
'No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.' this.dbSet = context.Set()
RepositoryBase
public class RepositoryBase<TEntity> : IDisposable where TEntity : class
{
internal ApplicationDbContext2 context;
internal DbSet<TEntity> dbSet;
public RepositoryBase(ApplicationDbContext2 context)
{
this.context = context;
this.dbSet = context.Set<TEntity>();
}
UnitOfWork
public class UnitOfWork : DbContext, IDisposable
{
private ApplicationDbContext2 context = new ApplicationDbContext2();
private RepositoryBase<Album> albumRepository;
I put the beginning for you to see, how can I fix ?? I tried to add dbContext, but i couldn't run.
"the need to create a RepositoryBase has arisen"<= Why? The typeDbContextis an implementation of a UoW pattern and the typeDbSet<T>is an implementation of a Repository pattern. Why re-wrap these types in your own implementation of the same pattern? You are adding nothing of value, just more code and a poor abstraction which results in code that is harder to read, debug, and use. In short, I strongly recommend you re-think this (and don't do it). - Igor