We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
EF Core 8.0 Fails Choosing The Right Constructor When Creating Entities From DB Having Multiple Constructors
In my test case, the Model.Lookups.ProjectItem entity provides three different constructors, each validating their constructor arguments:
Model.Lookups.ProjectItem
public ProjectItem(int id, bool isRequired, ItemDataType dataType); public ProjectItem(int id, bool isRequired, ItemDataType dataType, byte precision); public ProjectItem(int id, bool isRequired, ItemDataType dataType, KnowledgeCategory knowledgeCategory);
When reading data from the database, EF Core 8.0 does not use the proper constructor.
With this data:
… EF Core 8.0 fails to select constructor #3. It, instead, chooses constructor #1.
EF Core should select the right constructor from …
If a row has more non-null columns than constructor parameters available, these surplus values ought to be set using property initializers then.
https://github.com/SetTrend/EFC-Constructor-MRE
The text was updated successfully, but these errors were encountered:
Currently all constructor binding is static and non-configurable. Improvements to that area are tracked here: #10789
Also some documentation on what's currently possible: https://learn.microsoft.com/en-us/ef/core/modeling/constructors
Sorry, something went wrong.
No branches or pull requests
EF Core 8.0 Fails Choosing The Right Constructor When Creating Entities From DB Having Multiple Constructors
In my test case, the
Model.Lookups.ProjectItem
entity provides three different constructors, each validating their constructor arguments:Current Situation
When reading data from the database, EF Core 8.0 does not use the proper constructor.
With this data:
… EF Core 8.0 fails to select constructor #3. It, instead, chooses constructor #1.
Desired Situation
EF Core should select the right constructor from …
ordered by number of constructor parameters, descending
If a row has more non-null columns than constructor parameters available, these surplus values ought to be set using property initializers then.
Minimum Reproducible Example
https://github.com/SetTrend/EFC-Constructor-MRE
The text was updated successfully, but these errors were encountered: