All was working fine until I introduced Identity.
I changed my context class to be:
public partial class VisualJobsDbContext : IdentityDbContext<ApplicationUser>
{
private IConfigurationRoot _config;
public VisualJobsDbContext() { }
public VisualJobsDbContext(IConfigurationRoot config, DbContextOptions options) : base(options)
{
_config = config;
}...
and I have a Generic repository that is declared in the form:
public abstract class GenericRepository<C,T> : IGenericRepository<T> where T : class where C : IdentityDbContext<ApplicationUser>, new()
{
private C _entities = new C();
private VisualJobsDbContext context;
private DbSet<T> dbSet;
public GenericRepository(VisualJobsDbContext context)
{
this.context = context;
this.dbSet = context.Set<T>();
}....
The Error occurs on the
this.dbSet = context.Set<>();
the first time it gets hit. My OnModelCreating method does get called. The page I'm trying to get to from my MVC app does not require a login as it is a general page, but there will be areas that will require a login. However, I dont get as far as my controller Constructor method before it errors. To Register the service I have:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<VisualJobsDbContext>()
.AddDefaultTokenProviders();
and I can step this ok.
any ideas what I'm missing? I have looked at this stackoverflow answer and others, but it doesn't really help
In my OnModelCreating Method. I needed to place base.OnModelCreating(modelBuilder);
as my first line of code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.