I'am starting to use ASP.NET Identity(Blazor server with individual account). It creates two db contexts. One in : Areas/Identity/Data/AppDbContext.cs and the other one in Data/ApplicationDbContext.cs. In fact, in the appsettings.json i find two connection strings : "DefaultConnection" and "AppDbContextConnection". And i don't understand which I should delete and which of both is the right one to use. The error when i try to add a migration is : "More than one DbContext was found. Specify which one to use".
CodePudding user response:
This could happen when you scafolded the DbContext multiple times.
If you need to scaffold more than once a DbContext you should specify what that DbContext should be named (-Context
) and what connection string you want it to use (-Connection
), this way it will override the existing one instead of creating a new one.
Look at each DbContext and decide if you don't need one of them. If you decide to conserve both of them you will need to specify to what DbContext you want to apply the emigrations using the -Context
parameter.
For more informations about the commands and parameters consult the Microsoft Docs.