Search code examples
entity-frameworkedmxdatabase-metadata

Conversion between types in entity framework 6


I am getting the metadata from an edmx file so I can generate mappings for code first.

The challenge is: there is multiple types of the same name in two different namespaces and they don't convert. Is there a way to convert them?

Cannot convert from 'System.Data.Entity.Core.Metadata.Edm.EntityContainer' 
to 'System.Data.Metadata.Edm.EntityContainer'


Cannot implicitly convert type 'System.Data.Entity.Core.Metadata.Edm.AssociationSet[]' 
to 'System.Collections.Generic.IEnumerable<System.Data.Metadata.Edm.AssociationSet>'

Solution

  • The 'System.Data.Entity.Core.Metadata.Edm.EntityContainer' is the EF 6 Namespace.

    'System.Data.Metadata.Edm.EntityContainer' is from the old days... the System.Data.Entity.dll days.

    These classes are not compatible. Do not reference “System.Data.Entity” when using EF 6. If you use a component built against “System.Data.Entity.dll” it will not work with EF >= v6.