System.InvalidOperationException: Matching and metadata information not found for EntityType

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) to it. After that, the project compiles without any errors, but as soon as it calls the object of the self-monitoring object, the application creates a System.InvalidOperationException: information about the matching and metadata cannot be found for EntityType 'namespace.classname'.

I tried adding a second Entity Data model to a different namespace, but that doesn't help. If I remove the added .edmx file from the project, the problem will disappear. If I delete the entity tracking files (Model.tt and Model.Context.tt), the problem goes away.

It seems that Self-Tracking Entities cannot function normally when there is more than the Entity data model.

Has anyone else tested and solved this problem?

+4
source share
2 answers

Be sure to use consistent context creation throughout your decision.

Use the EF 5.x DbContext Generator for each of your entity data models. You can download the template through ExtensionManager (search for EF 5.x) or here

+1
source

I think that self-monitoring objects are not supported since 4.1 (DbContext) and beyond. We had a few problems at work when upgrading from 4 to 4.2 using ste, and we finished processing everything to use DbContext and get rid of ste. Since then it has been working like a charm!

0
source

Source: https://habr.com/ru/post/1401505/


All Articles