EF6到EF核心多对多关系映射

时间:2020-05-21 14:44:42

标签: entity-framework .net-core entity-framework-core

上课:

public class MarketTraitsDto
{
    [DataMember(Order = 1)]
    public int Id { get; set; }
    ...
    [DataMember(Order = 18)]
    public virtual ICollection<MarketTraitsDto> CompositeMarketTraits { get; set; }}

这是在EF6中配置的:

            HasMany(mt => mt.CompositeMarketTraits)
            .WithMany()
            .Map(mtmt => mtmt.ToTable("MarketTraitsLink")
                        .MapLeftKey("ParentMarketTraitId")
                        .MapRightKey("ChildMarketTraitId"));

尝试了各种各样的事情,有人为我迷惑不解地建议使用ModelBuilder在EF Core中进行编译的正确方法!

0 个答案:

没有答案