3
Vote

The type 'XXXX' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic

description

I'm getting the "The type 'XXXX' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject." error despite the type not being ignored, nested or generic.

I actually had this type working properly until I moved many of its properties off to a base type that I created on another library. I have the fealing having the base type on one library, and inheritor in another and the context in a third library seems to be causing the problem.

file attachments

comments

mgirgin wrote Dec 6, 2012 at 11:32 PM

Hi Ours -- could you please provide a repro for this issue?

Ours wrote Dec 14, 2012 at 7:40 AM

Hi mgirgin,

I've made a simple project where you can see the issue on https://github.com/fnicollier/EF5BugRepro. Renaming Library3.Message to something else works around the issue so I'm suspecting a namespace issue.

Thank you.

Ours wrote Dec 14, 2012 at 9:18 AM

This issue seems to popup in more obscure cases as well. We use the Universal Provider for ASP.Net authentication. As we use EF5 code-first, because of the lack of multi-tenancy (I read it's coming for EF6) I have to add the Universal Provider entities to my context. We have a couple of projects working like that fine.

But in one project that both runs autonomously and as a MvcContrib portable area. When we drop the portable area into another MVC4 project all of the sudden we get the same "I'm getting the "The type 'XXXX' was not mapped" but just for the Universal Provider types. If I kick them out of my context it all works fine. I suspect that because the "host" ASP.Net application has it's own authentication, there are multiple "User" classes in different namespaces and it confuses EF5.

The host was a SiteFinity instance that we migrated to MVC4 and added our portable areas to. As we don't have control over the Universal Provider class names, we where forced to remove them from the context and have it use a different DB to prevent both contexts from fighting each other. As a workaround (EF5 namespace issues) for a workaround (current lack of multi-tenancy) it works but I hope the underlying issue is fixed eventually.

Regards

Ours wrote Dec 15, 2012 at 1:57 PM

Zip of the repro project

moozzyk wrote Dec 17, 2012 at 8:36 PM

This is because you have 2 Message entities in the hierarchy. Currently this is not supported. As soon as you rename one of the Message entities the error should go away.

Ours wrote Dec 18, 2012 at 7:03 AM

Thank you, I'm aware of the workaround. I hope this gets fixed in the next version.
I did fall on a case where I couldn't rename the classes as they where part of the Universal Provider package. Stand-alone it worked fine but the moment I put the project as a MvcContrib portable area under SiteFinity, I get the same dreaded error message.

You have to admit it's a bit of a painful limitation for larger projects.

Kind regards,
Ours

glennc wrote Dec 19, 2012 at 11:50 PM

Consider in future

This is possibly a duplicate as this is a known issue.

Ours wrote Dec 20, 2012 at 7:01 AM

A straight bug is only a "consider in future"?

ajcvickers wrote Dec 20, 2012 at 5:36 PM

Hi Ours,

Unfortunately this is not simple to fix. The way mapping between types in the model and CLR types is implemented means that significant changes need to be made to allow multiple types with the same name. This is something we plan to work on, but it seems very unlikely that it will fit into the schedule for EF6 and hence, realistically speaking, this will not make it into EF until a future release.

Thanks,
Arthur