EF core many to many configuration not working with Fluent API

后端 未结 3 1819
粉色の甜心
粉色の甜心 2021-02-20 01:07

I am having trouble with understanding and implementing a many to many repationship using the FLuent API and EF Core.

I have looked at this question and set up my relati

3条回答
  •  广开言路
    2021-02-20 01:23

    For EF Core 5.0 and up, you may (finally) use direct relationships for many-to-many:

    modelBuilder
    .Entity()
    .HasMany(p => p.Tags)
    .WithMany(p => p.Posts)
    .UsingEntity(j => j.ToTable("PostTags"));
    

    Source: Relationships - EF Core | Microsoft (many-to-many)

提交回复
热议问题