tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Mapping and metadata information could not be found for EntityType (InvalidOperationException)

22 Apr 2010 1 mins Entity Framework

I updated my pretty big model today. Added absolutely simple table, no foreign keys, basic datatypes, simple PK. When I was calling CreateObjectSet<T> what a surprise - InvalidOperationException saying “Mapping and metadata information could not be found for EntityType”. That’s not so much descriptive.

Quick search thru internet resulted in suggestion that I’m missing some property in my POCO classes. I was not. I double checked it and I know that Entity Framework throws MetadataException listing all the missing properties (yep, I was there too, but it’s easy to fix). Another reason I found was that the metadata are not placed into resources or things are screwed up because of mixing two models in one project (to be clear, it is possible, but you have to carefully design your namespaces and names). Not the case either. I have only one model, metadata are there properly, other entity sets were working fine.

After loosing my mind slightly I found, rejected and then believed back again that it’s true, that you have misspelled property. I first rejected the idea because it was mixing the misspelled property and missing property together. And I knew about the MetadataException case. But the misspelled property actually results in InvalidOperationException exception with useless message.

Hopefully you’ll believe this (or any other solution found) faster than I did. 😃

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at www.tabsoverspaces.com.