You have a foreign key column name in your old database that does not comply with EF conventions, for example: the foreign key column in the Addresses table in the AddressTypes table for the AnAddressType relationship has the name MyCrazyAnAddressTypeNumberCodeKeyId .
But EF, by convention, suppose the column name is FK: [Nav.property]_[KeyColumn] . For example: If an AddressType has a PK named AddressTypeId EF, it is assumed that the FK column is named AnAddressType_AddressTypeId . Since this does not match you get the exception you are describing. You must provide the FK column name to resolve this issue:
modelBuilder.Entity<Address>() .HasRequired(a => a.AnAddressType) .WithMany() .Map(c => c.MapKey("MyCrazyAnAddressTypeNumberCodeKeyId")) .WillCascadeOnDelete(false);
(code snippet partially stolen from Ladislav's answer for convenience)
This is my hypothesis.
Edit
Alternatively, you can enter a foreign key property in your model and inform EF with data annotations that this property is FK for the corresponding navigation property:
public class Address { [ForeignKey("AnAddressType")] public int MyCrazyAnAddressTypeNumberCodeKeyId {get; set;} public virtual AddressType AnAddressType {get; set;} }
source share