-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration loop in m:n relation with custom schema #23937
Comments
/cc @AndriySvyryd @bricelam We fixed a bug where the join table was not in the same schema as the two other tables, but it looks like the snapshot might not have picked this up. |
But the problem occurs when the join table is in the same schema as tables that it joins |
@tomaschabada The workaround is to specify the schema explicitly: modelBuilder
.Entity<Student>()
.HasMany(l => l.Courses)
.WithMany(r => r.Students)
.UsingEntity(a => a.ToTable("CourseStudent", "my_schema")); |
I know there are workarounds. We will use one of them till the issue will be fixed |
I have a simple many to many relation defined between the
Course
andStudent
entitiesI configured both entities to use
my_schema
database schemaAfter running the generated migration, database tables are generated as expected
Autogenerated join table has the same schema as tables it is related to. And this is causing the poblems.
Each new migration will now include strange (and useless)
RenameTable
operation:I am using EntityFramework Core version 5.0.2.
I see in generated Snapshot migration file that
CourseStudent
entity maps to table without specifying the schemaWith this information missing, I suppose, the tool generating new migrations is stuck in a loop where it is changing the schema for join table, but forgetting to note this somewhere (snapshot).
The text was updated successfully, but these errors were encountered: