Mapping and metadata information could not be found for EntityType

Jun 8, 2012 at 6:49 AM


The below exception is crashing my IIS Express process on application startup.

It isn't giving me much to go on. Do you have an idea what is causing this?


System.InvalidOperationException crossed a native/managed boundary
  Message=Mapping and metadata information could not be found for EntityType 'NakedObjects.AbstractDomainObject'.
       at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)
       at System.Data.Objects.ObjectContext.GetEntitySetFromContainer(EntityContainer container, Type entityCLRType, String exceptionParameterName)
       at System.Data.Objects.ObjectContext.GetEntitySetForType(Type entityCLRType, String exceptionParameterName)
       at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity]()

Jun 8, 2012 at 7:06 AM

Ok. I found the problem, but perhaps you can help me understand it.

I have an inheritance structure in my entity model. B inherits from A.

I made a partial class for A (copied from another class) and there was a left over injected repository on it. When I remove the repository property, the error goes away. Now I don't need the repository in this case, but I would like to understand why I cannot inject a repository on a base class of an EF hierarchy.


Jun 8, 2012 at 7:12 AM

You can.  I think there was another problem.  It was somehow interpreting the injected repository as an entity type.. Did that property have the correct form for an injected service (a public set and a protected get)?  Was it being shadowed by another injected property on the sub-class or another partial class?

Jun 8, 2012 at 7:26 AM
It was of the correct form.
I cannot find any shadowing properties. Mmm. I'm probably missing something.
Jun 8, 2012 at 7:34 AM
Ok, yes, I was missing something. Found one shadowing property on one of the derived classes. :)
An explicit check and descriptive error message would be a nice to have for the future. :P
Jun 8, 2012 at 8:12 AM

If you were shadowing a property you should already have been receiving a warning at compile time in Visual Studio.  We recommend setting 'All warnings as errors' in Visual Studio, for just this type of reason.

Jun 8, 2012 at 8:38 AM
I thought of that too.