zzzprojects/EntityFramework-Effort

Editing an entity added in Effort no longer requires SaveChanges

thetopic opened this issue · 2 comments

When you add an entity in Effort, and then modify it, the modification is reflected in Effort without having SaveChanges.

For example, if I add these lines to Online Examples

Console.WriteLine(context.Companies.Single(c => c.Name == "Some name").Promo); // Y
companiesData.Single(c => c.Name == "Some name").Promo = "N";
Console.WriteLine(context.Companies.Single(c => c.Name == "Some name").Promo); // N expected Y

(https://dotnetfiddle.net/twOCIZ)

On the second line I modify the Promo property of the entity (Y --> N) and this modification is reflected in the context whereas I did not validate it with a SaveChanges.

Hello @thetopic ,

That's an expected behavior, you will have the same without Effort.

When an object is retrieved, the object is stored in the Change Tracker. When you retrieve it later, it will not create a new instance of the object but use the same one from that you previously retrieve and modified.

Let me know if the explanation about the current behavior is clear.

Best Regards,

Jonathan

Okay, okay. I just did a test on a small project with a simple DbContext and indeed you're right, I didn't understand it like that.