I have used IdentityDbContext in my project. My database has some tables which are connected to each other (relational). I want to use Repository pattern. I declared all my Interfaces. Then, I tried to Implement them. The problem is that I cannot create an instance of IdentityAppContext, because the constructor needs an input parameter 'option'. How can I implement them?
IdentityAppContext.cs :
public class IdentityAppContext: IdentityDbContext<AppUser, AppRole, int>
{
public IdentityAppContext(DbContextOptions<IdentityAppContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
public DbSet<AppUser> Users { get; set; }
public DbSet<Message> Messages { get; set; }
public DbSet<PM> PMs { get; set; }
public DbSet<Notification> Notifications { get; set; }
public DbSet<FileRepository> Files { get; set; }
}
IPmRepository.cs :
public interface IPmRepository
{
IEnumerable<PM> GetAllPMs();
PM GetPmById(int pmId);
bool InsertPM(PM pm);
bool UpdatePM(PM pm);
bool DeletePM(int pmId);
bool DeletePM(PM pm);
void Save();
}
PmRepository.cs :
public class PmRepository : IPmRepository
{
IdentityAppContext db = new IdentityAppContext();
public IEnumerable<PM> GetAllPMs()
{
}
public PM GetPmById(int pmId)
{
throw new NotImplementedException();
}
public bool InsertPM(PM pm)
{
throw new NotImplementedException();
}
public bool UpdatePM(PM pm)
{
throw new NotImplementedException();
}
public bool DeletePM(int pmId)
{
throw new NotImplementedException();
}
public bool DeletePM(PM pm)
{
throw new NotImplementedException();
}
public void Save()
{
throw new NotImplementedException();
}
}