-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
The entity type 'System.Uri' requires a key to be defined #3062
Comments
Looks like we are trying to bring it in as an Entity. I tried it in EF6 and interestingly we only bring it in to CSpace! |
It is missing a parameterless constructor, I think. |
See #3034 as well. For the short term at least these are both negative scenarios in which we find a property of a type that cannot be mapped, so we want to throw a helpful exception. Cc @smitpatel |
@divega No, the What's the work-around for this Declare the |
I was referring to System.Uri not having a parameterless constructor. Since System.Uri is not supported as a primitive property type (in either EF7 or EF6) we try to map it as structural object with its own properties. In EF7 we still don't support complex types so we try to make it an entity type in the model, but soon enough we will lrarn that it does not contain a property that we could automatically pick as the entity key (that is the exception you got). In EF6 we do support complex types, which don't need a key, so we can go a bit further, but ultimately can't succeed because we would need it to have a parameterless constructor. Yes the workaround is to map it as a string (you can still have a System.Uri property that wraps the string, and tell EF to ignore it) until the features Andrew pointed out are implemented. |
@divega Got it. Thanks. Will map for now. |
I think everything actionable from the EF side is already tracked by other issues. Feel free to reopen if you disagree. |
Added a URI field to my model (
Post.cs
).Adding a migration to record the new field results in
The entity type 'System.Uri' requires a key to be defined
error message:Why is this? What am I doing wrong?
https://github.com/bitcrazed/EFTestWebApp
The text was updated successfully, but these errors were encountered: