-
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
Data Annotation of Keyless Attribute on class can't override in Fluent API #24373
Comments
Use |
Hmm... I think that is what I was trying to do here but for some reason it doesn't work. I set a breakpoint and the code throws the error I showed before this code even fires in the OnModelCreatingPartial method. |
@jryutzy If the code is being scaffolded with [Keyless], then that means EF Core is not finding a suitable key in the database schema. It would be good to understand why this is happening if |
@jryutzy Thanks, that makes sense; we'll look into the null-ref bug. Note for triage: it seems to me that scaffolding could handle this case by introducing a key into the EF model based on the properties being at the principal end of the relationship. |
See #24369 for updating scaffolding to handle this case. |
@jryutzy have you tried this?
|
Related: #24789 |
I have an external table that I want to join up in LINQ. Below works to manually create the relationships between the External Table (SoftwareTools_Software) and TagCategory_X_Software IF in the SoftwareTools_Software class I remove the [Keyless] atrtribute. Is there anyway to remove the [Keyless] attribute using modelBuilder? I've tried all kinds of things and if the Keyless attribute is on my class I get this error. I don't want to manually remove from the code that was auto-generated by scaffolding the DB because the next time we scaffold I'd have to remove it again. There should be a way to overwrite the data annotation from modelBuilder. I've tried modelBuilder.HasAnnotation("Keyless", false); and that doesn't seem to work. Keep getting this error.
Message:
Similar issue as #20292 and #24283
The text was updated successfully, but these errors were encountered: