Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

New Post: Many-to-Many relationship not correctly generated

$
0
0
We have a table (Organization_XREF) that contains two foreign key columns (Parent_ID and Child_ID) that both refer to the same primary key column (OrganizationID) in the Organization table, as depicted in this diagram.

When we run EF RPCFG over this relationship, it generates the HasMany relationship in the Organization_OrganizationConfiguration class as follows:
HasMany(t => t.Organization_Organization).WithMany(t => t.Organization_Organization).Map(m => 
            {
                m.ToTable("Organization_XREF", schema);
                m.MapLeftKey("ChildId");
                m.MapRightKey("ParentId");
            });
This code will not compile. The compiler is unable to infer the type of the argument to HasMany, likely because there is no Organization_Organization property generated for the Organization_Organization model.

Has anyone else encountered a similar problem? How did you work around this? This is a critical issue for us, as it has broken our API.

Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>