2

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>'
Rick Rat
  • 1,732
  • 1
  • 16
  • 32
  • BTW I am trying to implment code like the "Reverse Engineer Code First" option from the power toys, which uses the EntityModelSchemaGenerator class, which is from regular EF, not 6. – Rick Rat Jul 15 '14 at 20:44
  • 1
    Are you doing this only because you need to customize the generated code or do you need to achieve something completely different? If the former, there might be easier ways, e.g. http://msdn.microsoft.com/en-US/data/dn753860. If the later, I would recommend looking at a more complete and robust implementation of reverse engineering into Code First like the one included in our tools (EF PowerToys was mostly a prototype). You can take a peek at the implementation here: https://entityframework.codeplex.com/SourceControl/latest#src/EFTools/EntityDesign/CodeGeneration/ – divega Jul 15 '14 at 21:54
  • Thanks Diego, I started with that, but I wanted to do more (repository, unit tests, etc), and couldn't replicate the parameters for those templates. I did use them to replicate them, but building the metadata from the edmx file, gives me the old namespace stuff. – Rick Rat Jul 15 '14 at 22:07

1 Answers1

3

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.

codeworx
  • 2,715
  • 13
  • 12