Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Trying to merge contexts Identity core and Application Context

$
0
0

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)
            {
                optionsBuilder.UseSqlServer("name=DefaultConnection");
            }
        }

        public DbSet<BmiInformation> BmiInformation { get; set; }

        public DbSet<WorkOuts> WorkOuts { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

            modelBuilder.Entity<BmiInformation>().ToTable("BmInformation");
        }
}

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

 public void ConfigureServices(IServiceCollection services)
 {

            services.AddDbContext<AppManagerDL.AppManagerDBContext>
              (options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
 ......

}
         

Any Ideas what could be wrong.

Error

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.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>