How to specify the name of a relationship in the code - first, many, many relationships

When I create two objects with many relationships, it will generate a relationship table in the database, is it possible to specify a table name?

+4
source share
1 answer

Yes, but you need to use the free API:

mb.Entity<FirstEntity>() .HasMany(a => a.SecondEntities) .WithMany(b => b.FirstEntities) .Map(mc => { mc.ToTable("YourTableName", "YourDbSchema"); mc.MapLeftKey("FirstEntityKeyColumnName"); mc.MapRightKey("SecondEntityKeyColumnName"); }); 
+4
source

Source: https://habr.com/ru/post/1399748/


All Articles