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

How to disable key #4434

Closed
maloo opened this issue Jul 29, 2023 · 3 comments
Closed

How to disable key #4434

maloo opened this issue Jul 29, 2023 · 3 comments

Comments

@maloo
Copy link

maloo commented Jul 29, 2023

Hi,
when mapping a type to Json, having an "int Id" will make it fail. How do I tell EF Core that Id is NOT a Key? Please add that to this page. Now it just shows how to tell EF Core WHAT is a Key. I tried renaming Id to like NotId and that works (but I need it to be called Id), I also tried [Keyless] but that gave me another error ...


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@ajcvickers
Copy link
Contributor

@maloo modelBuilder.Entity<Foo>().HasNoKey().

@maloo
Copy link
Author

maloo commented Jul 29, 2023

I tried [Keyless] which I guess is the same but it still failed. I reached out to SO and got some help. The exceptions related to keys and ordinal keys in Json columns are really hard to decode. Please update the docs around this (or fix the Id column issue with Json columns).

Here's the SO issue: https://stackoverflow.com/questions/76789993/why-cant-i-map-an-array-of-child-items-to-json

BTW I think there's a bug in one of the Json column validation messages. The use of .First() to get a parameter for the message on an empty enumerator throws so you don't get the error message of the exception.

@ajcvickers
Copy link
Contributor

ajcvickers commented Aug 6, 2023

Duplicate of #29380.

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

No branches or pull requests

2 participants