dotnet-starter-kit icon indicating copy to clipboard operation
dotnet-starter-kit copied to clipboard

Duplicate migrate table

Open Haytham-Natej opened this issue 1 year ago • 4 comments

When relate multiple tables in different dbcontext and different schema, it duplicates the creation of the tables.

Haytham-Natej avatar Jan 29 '25 09:01 Haytham-Natej

If you add navigation between schema's it will create and include it in each schema referenced. Rather add a column to referencing an entity outside of the schema and handle it in code only. No "hard" references. I am sitting with the same challenge. I would rather then add hard fk references outside of ef to the db to enforce relationship.

kallievz avatar Jan 31 '25 12:01 kallievz

I solved this issue using

ExcludeFromMigrations()

😅

Haytham-Natej avatar Jan 31 '25 13:01 Haytham-Natej

On declaring the entity? Perhaps share a code snippet as to where to place it please?

kallievz avatar Jan 31 '25 22:01 kallievz

modelBuilder.Entity().ToTable("Genders", schema: "refData", t => t.ExcludeFromMigrations());

Haytham-Natej avatar Feb 09 '25 07:02 Haytham-Natej