Water Cooler v2
Water Cooler v2

Reputation: 33850

System.InvalidOperationException: Mapping and metadata information could not be found for EntityType Foo.Bar

I am at my wit's end trying to resolve this.

I have a pretty significantly large MVC project using 4 Entity Framework models. The models are compiled into a separate assembly/class library type project.

Until a few days ago, everything was working fine. I was on leave for 2 days and someone tweaked the model and he's called severely sick.

When I came back today, I noticed that the app just won't start. It shows you the yellow screen of death with the following exception message:

System.InvalidOperationException: Mapping and metadata information could 
not be found for EntityType 'MyNamespace.MyClassName'

I checked out a few articles (http://blogs.infosupport.com/mapping-and-metadata-information-could-not-be-found-for-entitytype-schema-klant/, http://matheusandcode.wordpress.com/2011/11/13/mapping-and-metadata-information-could-not-be-found-for-entitytype/) and questions & answers from here and they all suggest that I cross-check for misspellings or missing properties between the POCO's and the model generated entities.

I have about 400+ entities. However, I checked the entity that it throws an exception while creating the entity set of, and there are absolutely no spelling mismatches. I've spent over 5 hours on checking this and I am tired and frustrated.

Anyone have any other leads as to the possible causes for this error?

I've cleaned, rebuilt, checked for spelling errors, missing properties, cross-checked parity between the conceptual and storage model using the Table Mappings window, the model browser and even SQL Server Management Studio, I've taken print-outs and marked every property on paper against the one in the POCO, I've rinsed and repeated a few times, but the error just won't go.

I am using Visual Studio 2010, EF 5, MVC 4 and the Entity Framework POCO Generator package.

Upvotes: 1

Views: 3848

Answers (1)

Water Cooler v2
Water Cooler v2

Reputation: 33850

For the benefit of the weary wayfarer.

In our case, we spotted the error to the following cause:

A developer had added an extra EDMX that did not use the EF POCO generator. In fact, the new model had no tables either. It just used a stored procedure.

He removed it and the error went away. We'll probably call the stored proc using vanilla ADO.NET instead of adding a new Entity Framework model for it.

Upvotes: 2

Related Questions