4

I have an ASP.NET 4.0 web application that uses Entity Framework 4.3.1 and Self-Tracking Entities. It works fine until I add another ADO.NET Entity Data Model (.edmx) file to it. After that the project compiles without any errors, but as soon as it calls a self-tracking entity object, the application produces the System.InvalidOperationException: Mapping and metadata information could not be found for EntityType 'namespace.classname'.

I have tried adding the second ADO.NET Entity Data Model into a different namespace - but that does not help. If I remove the added .edmx file from the project, the problem disappears. If I remove the Self-tracking entity files (Model.tt and Model.Context.tt), the problem disappears.

It looks like Self-Tracking Entities cannot function properly when there is more than Entity Data Model.

Has anyone else experienced and solved this problem?

SHS
  • 151
  • 5

2 Answers2

1

Make sure to use consistent Context generation throughout your solution.

Use the EF 5.x DbContext Generator on each of your Entity Data Models. You can either download the template via the ExtensionManager (search for EF 5.x) or here

Sid
  • 1,245
  • 2
  • 20
  • 44
Alechandro
  • 426
  • 3
  • 13
0

I think self tracking entities are not supported from 4.1 (DbContext) onwards. We had a few problems at work when upgrading from 4 to 4.2 with ste and we ended up reworking all to use DbContext and getting rid of ste. Since then it works like a charm!

Pierrick
  • 37
  • 2
  • 5
  • Self-Tracking entities are working for 4.3.1 The problem I found is that they are working when there is one ADO.NET Entity Data Model only. If you add more, it stops working. – SHS Mar 15 '12 at 03:26