Change name of generated Join table ( Many to Many ) - EF Core 5

Armin Shoeibi

How to change name of a join table that EF Core 5 Created ?

for example

 public class Food 
    {
        public int FoodId { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public string Ingredients { get; set; }
        public string PhotoPath { get; set; }
        public ICollection<Menu> Menus { get; set; }
    }

  public class Menu
    {
        public int MenuId { get; set; }
        [Column(TypeName = "date")]
        public DateTime MenuDate { get; set; }
        public bool IsPublished { get; set; }
        public ICollection<Food> Foods { get; set; }
    }

and the join table for this 2 entities named FoodMenu, I want to change it to something else..

Ivan Stoev

You can use one of the UsingEntity method overloads, for instance UsingEntity(Action<EntityTypeBuilder>).

Since it is a relationship fluent configuration API, you first need HasMany + WithMany pair, e.g.

modelBuilder.Entity<Food>()
    .HasMany(left => left.Menus)
    .WithMany(right => right.Foods)
    .UsingEntity(join => join.ToTable("TheDesiredName"));
   

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Laravel 5 Many to Many - Table name in singular

From Dev

EF6 Many to Many relationship, multiple tables to join table

From Dev

How express the many to many relationship with single parent table in EF 5

From Dev

Core Data Join Table Many to Many Relationship - Object Creation

From Dev

Many to many MVC 5 Model Code first join table

From Dev

Many to Many relation with join table

From Dev

ef core many to many relation controller

From Dev

Mass deletion of references in EF Core (Many to Many)

From Dev

JPA many to many relation not inserting into generated table

From Dev

Return one column from a many-to-many join table in EF6

From Dev

Return one column from a many-to-many join table in EF6

From Dev

Duplicate entries in EF7 join table for many-to-many relationship

From Dev

How to operate on the table many to many EF

From Dev

Many-to-Many Relationships to Same Table with EF

From Dev

How to operate on the table many to many EF

From Dev

EF Code First many-to-many: how to specify name of th third table and add some other properties to it?

From Dev

EF Code First many-to-many: how to specify name of th third table and add some other properties to it?

From Dev

Defining a many-to-many relationship referencing the same table (EF7/core)

From Dev

Direct implementation of EF Core many-to-many relationship unable to detect the related table

From Dev

DB migration generating wrong table design in EF Core (Many-To-Many with AspNetUsers)

From Dev

Save Related Data (Many to Many) in EF Core 5 without getting the actual records

From Dev

SQL join on junction table with many to many relation

From Dev

Many to many association without join table

From Dev

Sequelize not creating join table many-to-many

From Dev

Hibernate many-to-many join table not populating

From Dev

Doctrine many-to-many join table not populating

From Dev

Rails: many to many relationship join table design

From Dev

foreignKey or inverseForeignKey for many-to-many join table

From Dev

Is a "join table" the result of a SQL JOIN, or the table between a many-to-many

Related Related

  1. 1

    Laravel 5 Many to Many - Table name in singular

  2. 2

    EF6 Many to Many relationship, multiple tables to join table

  3. 3

    How express the many to many relationship with single parent table in EF 5

  4. 4

    Core Data Join Table Many to Many Relationship - Object Creation

  5. 5

    Many to many MVC 5 Model Code first join table

  6. 6

    Many to Many relation with join table

  7. 7

    ef core many to many relation controller

  8. 8

    Mass deletion of references in EF Core (Many to Many)

  9. 9

    JPA many to many relation not inserting into generated table

  10. 10

    Return one column from a many-to-many join table in EF6

  11. 11

    Return one column from a many-to-many join table in EF6

  12. 12

    Duplicate entries in EF7 join table for many-to-many relationship

  13. 13

    How to operate on the table many to many EF

  14. 14

    Many-to-Many Relationships to Same Table with EF

  15. 15

    How to operate on the table many to many EF

  16. 16

    EF Code First many-to-many: how to specify name of th third table and add some other properties to it?

  17. 17

    EF Code First many-to-many: how to specify name of th third table and add some other properties to it?

  18. 18

    Defining a many-to-many relationship referencing the same table (EF7/core)

  19. 19

    Direct implementation of EF Core many-to-many relationship unable to detect the related table

  20. 20

    DB migration generating wrong table design in EF Core (Many-To-Many with AspNetUsers)

  21. 21

    Save Related Data (Many to Many) in EF Core 5 without getting the actual records

  22. 22

    SQL join on junction table with many to many relation

  23. 23

    Many to many association without join table

  24. 24

    Sequelize not creating join table many-to-many

  25. 25

    Hibernate many-to-many join table not populating

  26. 26

    Doctrine many-to-many join table not populating

  27. 27

    Rails: many to many relationship join table design

  28. 28

    foreignKey or inverseForeignKey for many-to-many join table

  29. 29

    Is a "join table" the result of a SQL JOIN, or the table between a many-to-many

HotTag

Archive