-
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
Allow EF to call parameterized entity constructors #10703
Comments
@codepb This is already implemented in the 2.1 code. You might consider giving it a try using our nightly builds, which are listed on the homepage: https://github.com/aspnet/EntityFrameworkCore |
Excellent news, thanks! I didn't see an issue for this already, so apologies if I missed that. |
Can we have Ef replace immutables, as described here? Think currently with the use case you would have to manually detach the old entity and reattach the new entity. |
Note for triage: work still to be done here:
|
Closing this as fixed, with additional work tracked in #10789 |
When trying to create classes with only readonly properties, you currently have to use properties with backing fields to be able to construct with Entity Framework, and it is required to have an empty constructor. It would be preferable if Entity Framework could construct the objects by passing the values to a constructor with a parameter of the same name (much like JSON.net can). This would allow truly readonly properties, and keep the class simpler.
Steps to reproduce
It would be preferable to support a class structured like the following:
Further technical details
EF Core version: 2.0.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
The text was updated successfully, but these errors were encountered: