EF6 Code First - may cause cycles or multiple cascade paths

╄→尐↘猪︶ㄣ 提交于 2019-11-30 14:06:58

Using Fluent API:

        //player - national team relations
        modelBuilder.Entity<Player>()
            .HasRequired<Team>(p => p.National)
            .WithMany()
            .WillCascadeOnDelete(false);

        //player - club team relations
        modelBuilder.Entity<Player>()
            .HasRequired<Team>(p => p.Club)
            .WithMany()
            .WillCascadeOnDelete(false);

I think the fact that your Team only has a single navigation property for two different foreign keys pointing to it might be a problem with your EF code. It's probably more acceptable to have two navigation properties on your Team - one for each foreign key pointing to it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!