TableBuilder.ExcludeFromMigration is not Excluding transitive dependencies #35725
Labels
area-migrations
closed-no-further-action
The issue is closed and no further action is planned.
customer-reported
Bug description
I have a project where i use multiple DbContexts, which can have dependencies to one another. The migrations should be managed by one DbContext only, to not have multiple migrations adding/changing the same entities.
For that use case, i want to exclude specific entities and all of it dependent entities from migrations.
Using
modelBuilder.Entity<ENTITYTYPE>().ToTable(t => t.ExcludeFromMigration())
is excluding the entity but not its dependencies, which defeats the purpose of using that method in my use case.It is possible to add
ExcludeFromMigration
for every Entity, but that would need to be maintained continually and the bigger problem are Many-To-Many-Relationships on convention which will create Join-Tables, that don't have a EntityType represented in code.Your code
Stack traces
Verbose output
EF Core version
9.0.2
Database provider
Microsoft.EntityFrameworkCore.Sqlite
Target framework
.NET 9.0
Operating system
Windows 11
IDE
Visual Studio 2022 17.13.0
The text was updated successfully, but these errors were encountered: