-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Hi,
Situation
Assume that we have created a modular application and we have more than one DbContext.
Example: In our core part of the application, we have a CommonDbContext:
public class CommonDbContext : DbContext
{
//common entity DbSet properties
}And we have several modules (in their own assemblies), like:
public class BlogModuleDbContext : CommonDbContext
{
//Blog module's additional entity DbSet properties
}
public class ChatModuleDbContext : CommonDbContext
{
//Chat module's additional entity DbSet properties
}In this case, I want to have 3 separated migrations normally:
- Migration for CommonDbContext .
- Migrations for BlogModuleDbContext (which should not include CommonDbContext entities).
- Migrations for ChatModuleDbContext (which should not include CommonDbContext entities).
At this point, as you know, derived DbContext's automatic migration generation code include base DbContext (CommonDbContext) changes. While this can be desired in some situations, as you see it's not good for my application.
Feature Request
Define an attribute (and a method in fluent configuration) to ignore base changes:
[IgnoreBaseDbContextMigrations]
public class BlogModuleDbContext : CommonDbContext
{
//Blog module's additional entity DbSet properties
}Entity Framework migration generator should understand IgnoreBaseDbContextMigrations attribute and should not detect base class changes.
IgnoreBaseDbContextMigrations can be enhanced. For example, we may supply a DbContext class type to indicate which will be ignored, and so on... Also, there can be technical problems on some situations (for example, on entity inheritance) which should be thought carefully.
What do you think for such a feature, or do you know any other approach to implement the same requirement?