Trying to merge contexts Identity core and Application Context RRS feed

  • Question

  • User-183185495 posted

    Hi I have two contexts my identity core and application context I am using .net core 3.1 but I am having an issue where it says the following.

    public class AppManagerDBContext : IdentityDbContext
            public AppManagerDBContext(DbContextOptions options) : base(options) { }
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
                if (!optionsBuilder.IsConfigured)
            public DbSet<BmiInformation> BmiInformation { get; set; }
            public DbSet<WorkOuts> WorkOuts { get; set; }
            protected override void OnModelCreating(ModelBuilder modelBuilder)

    I have the context injected into the services statup configuration element.

     public void ConfigureServices(IServiceCollection services)
                  (options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

    Any Ideas what could be wrong.


    The DbContextOptions passed to the AppManagerDBContext constructor must be a DbContextOptions<AppManagerDBContext>. When registering multiple DbContext types make sure that the constructor for each context type has a DbContextOptions<TContext> parameter rather than a non-generic DbContextOptions parameter.
    PM> Add-Migration MyFirstMigration -Context AppManagerDBContext
    Build started...
    Build failed.

    Friday, May 15, 2020 2:20 PM

All replies

  • User-474980206 posted

    The error is pretty clear. Your constructor does not have the correct parameters to use with add dbcontext. Try following the suggested fix

    public AppManagerDBContext(DbContextOptions<AppManagerDBContext> options) : base(options) { }

    Friday, May 15, 2020 2:45 PM