Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Message on Keys Not Being Allowed on Derived Type..But It's Not a Derived Type #5151

Closed
markolbert opened this issue Apr 22, 2016 · 1 comment

Comments

@markolbert
Copy link

I wrote this up over on stackoverflow (http://stackoverflow.com/questions/36797464/ef7-keys-on-derived-type-but-its-not) but thought I'd mention it here.

Summary version: I have two simple, related classes on which I am trying to define keys using the fluent api (I switched from using data annotations because the child class uses a composite primary key, one of whose elements is a foreign key back to the master class, and composite primary keys are not supported in EF7 via annotations).

When I run dnx ef migrations add [name], I get an error that the classes "cannot have keys other than those declared on the root type". But they are not derived types (well, they're derived from object, implicitly, but nothing else).

@smitpatel
Copy link
Contributor

dupe of #3727
The class Site contain property of type object. Which is being discovered as navigation because TypeMapper cannot map object to any SqlServer Type. That adds object as entity type in the model. Since all classes are implicitly derived from object, every other entity type becomes derived type of entity type representing object.
In #3737, we blocked discovering object as navigation since it causes above and the error message becomes to hard to understand what is exactly happening. It will be shipping in RC2 release.
After the fix, when you have property of type object following is the error message.
The property 'Site.Parameters' could not be mapped, because it is of type 'object' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants