I am using Asp net core 3 application visual studio it has the following :
project as RazorPages with the structure wwwroot, Models, Pages, Services, appsettings, Startup, and Program
Folders:
- Model => PrimaryDBContext => It is my primary DBcontext, I need to set up this context in Startup as primary and the context from DataService as secondary
- Services => DataService: It has the secondary DBContext (I have it as my secondary context from a main project that contains Users (table) ). I use this DBContext for Login (to claim user identity) to use it only for email and Password credentials.
-appsettings => It has the two connections string for my primary and secondary context
The issue is when I want to create migration is says that there is a conflict between the context. It does not allow to create the migration for the project.
How could I set up my primary context and secondary context to create migration?
(I don't want to include secondary context for migration)
How could I define in the project that my primary context is the context to pick up for the migration?
thank you in advance
What I have tried:
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IDataService, DataService>();
services.AddDbContext<PrimaryDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("PrimaryDbConnString")));
services.AddScoped<SecondaryDbContext>(options => new SecondaryDbContext(Configuration.GetConnectionString("SecondaryConnString")));
}