c# - Entity Framework does not recognize many to many relationship with custom join table -
i've got 3 tables/entities
public class test { public int id {get; set;} public virtual icollection<testquestion> testquestions { get; set;} public virutal icollection<question> questions {get; set;} } public class question { public int id {get; set;} public virtual icollection<testquestion> testquestions { get; set;} public virutal icollection<test> test {get; set;} } public class testquestion { public int id {get; set;} public int testid { get; set; } public virtual test test { get; set; } public int questionid { get; set; } public virtual question question { get; set; } public int order { get; set; } }
and context containing dbset set each of them. entity framework not recognize testquestion join table.
modelbuilder.entity<question>() .hasmany(x => x.tests) .withmany(y => y.questions);
i have tried doing configuration using map ef tries create new table instead of using custom. why not recognize join table during query tests , questions collection empty , testquestion collection not.
Comments
Post a Comment