且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

许多一对多使用EF code首先关系

更新时间:2023-02-07 15:14:45

去图,经过一个小时左右的搜索,我去找到确切答案,30秒后我张贴我的问题。

Go figure, after an hour or so of searching, I go and find the exact answer 30 seconds after I post my question.

解决的办法是添加以下上下文类:

The solution was to add the following to the context class:

modelBuilder.Entity<Vendor>()
                .HasMany<Questionnaire>(x => x.OpenQuestionnaires)
                .WithMany(x => x.Vendors)
                .Map(x =>
                    {
                        x.MapLeftKey("vID");
                        x.MapRightKey("qID");
                        x.ToTable("VendorQuestionnaires");
                    });

我找到了答案通过阅读这个堆栈溢出职位:的 EF code首先许多到许多不工作