I have a DbContext this kind
public class ApplicationDbContext : IdentityDbContext<User, UserGroup, int> { public DbSet<Xxx1> Xxx1 { get; set; } public DbSet<Xxx2> Xxx2 { get; set; } public DbSet<Yyy1> Yyy1 { get; set; } public DbSet<Yyy2> Yyy2 { get; set; } } I need to make it so that when migrating everything regarding the tables Xxx participated in the migrations, and Yyy was ignored.
It is also necessary to ignore all tables related to IdentityDbContext
How can this be done?
Why do I need it.
I make a system of modules for the site. Site base is SiteCore
Each module may contain additional tables in relation to SiteCore
But for convenience, Linq queries into the database module can also work with SiteCore tables (and other modules, if it depends on them).
In order for migrations to work with this approach, I need to make a separate migration table for each module (the table name can be configured in EF). But the problem is that the module can contain tables that are in other modules, and this will break the migration, since then several migrations in different modules will be responsible for the same table.
Therefore, I need to exclude some tables from the migrations of a specific module.
It is also desirable that when db.EnsureCreated these tables also did not participate.
Here is a related question , where I try to use another approach for the whole situation, but at the moment the approach is chosen from the current question.
Added by:
While thinking about this solution:
Make two contexts, one for migrations, the second for work. When creating a database or working with migrations, I will use a shorter context where Yyy commented out.
And for work inside the module I will use the normal full context.
public DbSet<Yyy1> Yyy1 { get; set; }public DbSet<Yyy1> Yyy1 { get; set; }public DbSet<Yyy1> Yyy1 { get; set; }public DbSet<Yyy2> Yyy2 { get; set; }public DbSet<Yyy2> Yyy2 { get; set; }public DbSet<Yyy2> Yyy2 { get; set; }- pasha goroshko