Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Reverse POCO Code First Generator Many-to-Many Relationship Refers to Model Property that Does Not Exist

We have a recently introduced 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:

table structure

When we run EF Reverse POCO Code First Generator over this relationship, it generates the HasMany relationship in the Organization_Organization Configuration 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.

like image 640
Mike Hofer Avatar asked Dec 12 '14 15:12

Mike Hofer


1 Answers

As it turns out, this was a defect in the product. The tool's author (Simon Hughes) kindly contacted me to let me know the issue has been resolved in v2.10.0.

like image 82
Mike Hofer Avatar answered Nov 14 '22 22:11

Mike Hofer