I've been trying to make a connection of two schemas in my application.
I'll explain to you: I have an application that uses its own tables, so I created those with a migration and models and DbContext, then I hosted the tables in a SQL Server database that has other schemas from other applications and everything is ok. The single application connects and receive data.
But my application needs to be connected to one of the other schemas that I have in my SQL Server database, the other schema has the same connection string because they are in the same server.
I also wrote the 2 db context in startup.cs / ConfigureServices
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(_config.GetConnectionString("TrialOrdersConnectionString"), x => x.MigrationsHistoryTable("__MyMigrationsHistory", "trials")));
services.AddScoped(p => new ApplicationDbContext(p.GetService<DbContextOptions<ApplicationDbContext>>()));
//services.AddDbContext<AppDbContext_serie>(options => options.UseSqlServer(_config.GetConnectionString("Serie0ConnectionString")));
But of course, as I don't really have the applicationDbContext of the other schema is not recognized.
I tried to repeat the application db context of the other schema to have the models and call them but in my migration it creates again the database :( and I don´t want that.
I am using .Net Core and Angular.