-
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
Scaffolded collection navigation properties do not have setters #30286
Comments
Note for triage: it's unfortunate that this prevents the collection from being serialized, at least in System.Text.Json. We should consider adding the setter back because of this. @giarico You can customize the T4 template to create setters. |
Thanks, @ajcvickers - I will add this as default in the next version of the templates supplied with EF Core Power Tools |
Note from triage: we will change the default back to collections with setters, and take this to Tactics for a 7.0.x patch. |
Hello! Thanks! |
@jmoralesv you can use EF Core Power Tools with T4 templates today or use your own t4 template. |
@jmoralesv This will be in the 7.0.5 release, as indicated by the milestone. |
@ajcvickers thank you! I think it will be available in April 2023, if I'm not mistaken. Is there a way to have access to the fix through NuGet, so we can test the fix? I can see only a preview for version 8.0 at the moment: https://www.nuget.org/packages/Microsoft.EntityFrameworkCore#versions-body-tab That way we can have that already fixed in our project, and we can switch to the final release version once it is available in April. Thanks! |
I have updated to EF Core 7.0.5 and regenerated the code using EF Core Power Tools but the collection still only has getter. |
Someone need to update the EF7 Tools in Power Tools to 7.0.5 |
@janseris Fixed in latest daily |
@ErikEJ this is still an issue today. Visual Studio 17.6.5 Command used :
All my collections look like this, in all my models : public virtual ICollection<Item> Item { get; } = new List<Item>(); Did I do something wrong ? Edit : using the T4 templates is still a valid workaround. |
@fschlaef Update your Tools package? |
Okay, this is embarrassing ... After properly updating to 7.0.9, it is indeed working correctly and T4 templates are no longer required. Thank you @ErikEJ for the help ! |
Hello,
With EF7 all child entities are get only collections.
If I use the generated entities for deserialization, the child entities remain null.
Example of an entity with a child collection. Before EF7 it was get & set.
When I try to deserialize the returned json to the ComplaintType object, the LocalizedComplaintTypes property is null
return await httpClient.GetFromJsonAsync<IEnumerable<ComplaintType>>(...);
If I modify the ComplaintType class putting set or init on LocalizedComplaintTypes property, it works.
Why this change in EF7? I had a lot of drawbacks... and not limited to this.
What is the workaround?
The text was updated successfully, but these errors were encountered: