question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setter removed from Entity for Child Entities in EF 7

See original GitHub issue

This piggybacks on #1582 and #1587, of which both are marked closed. @ErikEJ asked in both threads why would someone want to reassign the navigation property. In my case we have several places where we sort the collection after it has been returned from the database.

class.Students = class.Students.OrderBy(s => s.Property).ToList();

Obviously a trivial example. The collection of class.Students could have been originally retrieved from the database with or without a sort. It could have been added to after the original query, etc. However we need the final collection sorted in place. Of course there are work arounds like clearing the original collection and adding to it a sorted one, using .Sort(), or customizing the T4 templates. However I’m trying to understand whether our usage goes against best practices? What is the proper/recommended way of solving this? There must be a reason why child properties are now read only. This was not clear from both closed items referenced above.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Apr 13, 2023

Where does 7.0.5 come into play?

@btcalit Good question! The reverse engineering “engine” is packed as a .NET command line tool, and that tool now uses EF Core 7.0.5.

1reaction
ErikEJcommented, Apr 13, 2023

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffolding in EF7 no longer produce 'setter'
I am aware that I should not use the entity model for any kind of business logic. I am doing this because it...
Read more >
Change Detection and Notifications - EF Core
When a dependent/child entity is going to be deleted because a required relationship has been severed. This detects when an entity should not...
Read more >
EF Core 7: It Just Keeps Getting Better
It's no surprise that Julie's excited about the latest EF release. It's faster, it allows bulk updates and deletes, it lets you map...
Read more >
Don't let Entity Framework call the shots - Fear of Oblivion
Don't let Entity Framework call the shots. With .NET Core, Entity Framework is the default choice when it comes to database access.
Read more >
How do I remove Included Child entities properly with EF ...
I am getting entity using SingleOrDefault and remove children entity using Remove(). This doesn't work in Entity Framework Core 6.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found