Created ASP Net Core application with authorization, tried to execute in console NuGet

Add-Migration Initial 

received an error message

 More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands. 

I think the problem is that there are 2 data contexts. One from Identity, the other from me

 public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // Customize the ASP.NET Identity model and override the defaults if needed. // For example, you can rename the ASP.NET Identity table names and more. // Add your customizations after calling base.OnModelCreating(builder); } } 

How to combine them?

 public class MobileContext : DbContext { public DbSet<Phone> Phones { get; set; } public DbSet<Order> Orders { get; set; } public MobileContext(DbContextOptions<MobileContext> options) : base(options) { } } 

It seems to have found a solution, I could not figure out on my own what exactly needs to be done. Forum with a solution

  • on the forum, by reference, one of the two contexts is proposed To perform the migration for ApplicationDbContext, try this: PM> Add-Migration InitialApplication -Context ApplicationDbContext - Ruslan_K
  • Why do you need 2 contexts? IdentityContext is essentially the same database context, just with a few extra tables - Buka
  • Authorization of users and data in different places. - Ivan Stotsky

0