This project is read-only.


Table splitting: InvalidOperationException - sequence contains more than one matching element


I have a repro for what I think might be an EF bug. I would like to split one table across two entities. Each of those entites contains a reference to a third entity. The two references must be exposed with identical foreign key property names. Since they map to columns in the same table, configuration (or, in this example, an attribute) is used to make the column names unique.

When I try to load the model, I get the above exception from EF. If I modify the name of one of the FK properties then the error goes away.

For the complete description of the problem and the source code to reproduce it, see
Closed Jul 5, 2013 at 8:55 PM by maumar
Verified, added functional tests - closing


BriceLambson wrote Nov 5, 2012 at 8:19 PM

This looks like a bug in Code First.

At one stage in the Code First pipeline, when determining the destination column for foreign keys, the column names are not yet configured and are instead set to the entity property names. An ambiguity arises because both property names are the same.

Changing one of the property names is a valid workaround until this gets fixed.

lukew wrote Nov 5, 2012 at 9:14 PM

We are investigating this issue and will discuss at the weekly team sync up tomorrow

wst wrote Apr 23, 2014 at 2:46 PM