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.

[FEATURE] DB Context Factory / EFCore 6 Change Tracking challenges

See original GitHub issue

Is your feature request related to a problem? Please describe. As context, I’ve always been a fan of accessing and creating dbcontexts when I’ve needed to do multiple db related actions. I feel with this project I should give in and simply adopt the context factory method but no idea how I’d go about doing that. Problem I’m running into is I’ve added an ICollection<Hero> Heroes to the user class but when trying to create it, I continuously getting change tracking problems.

Describe the solution you’d like Add ICollection<Hero> Heroes to the User class and adopt (if it’s the right solution) a db context factory

Describe alternatives you’ve considered I did wonder about scoped vs transient but I feel the context factory might fit better

Additional context None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rhysjtevanscommented, Mar 11, 2022

So it’s probably my lack of dotnet aspnet knowledge but I think what I’m going to do moving forward is use the repository if I’m interacting with the database entities in any way and then the service to map the entity to a Dto to transfer to the client,

1reaction
rhysjtevanscommented, Mar 2, 2022

Forgot to say, also love the boilerplate!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking changes in EF Core 6.0
Complete list of breaking changes introduced in Entity Framework Core 6.0.
Read more >
Change Tracking - EF Core
EF Core change tracking works best when the same DbContext instance is used to both query for entities and update them by calling...
Read more >
How to Avoid Common Pitfalls and Challenges of EF6
EF6 can cause performance issues in applications, due to inefficient queries, lazy loading, tracking changes, or database migrations. To improve the performance ...
Read more >
Change Tracking Issue with Entity Framework Core in ...
I've been experimenting with Entity Framework Core 5.0 using .Net Core (3.1) Class Libraries and Console App. I've created 2 demo classes in ......
Read more >
Do you use any of the Entity Framework Core tracking ...
SaveChanges() is the core method used to persist data to the context. It requires change tracking to know which fields to update. It...
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