Skip to content
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

Support store-generated values that are both written to and also read back from the database in the same command #23196

Open
Tracked by #22959
victorgoebel opened this issue Nov 5, 2020 · 1 comment

Comments

@victorgoebel
Copy link

I searched on the issues and did not find something similar and I asked on StackOverflow first and I was told this featured does not exist, so I'm asking here next if this feature exists and if this does not exist I would politely ask for this to be added to the backlog as a feature request.

I have a scenario where I do something similar to this:

var customer1 = await efContext.Customers.SingleAsync(...)
customer1.reference = "ABCD";

var customer2 = await efContext.Customers.SingleAsync(...)
customer2.reference = "XYWZ";

efContext.SaveChanges();

The database has a trigger that overrides references based on some criteria/rule, so customer1 might stay with ABCD in the reference field, but customer2's reference might be overridden to HELLO-XYWZ via the database trigger.

When that happens, my entity in memory is wrong after SaveChanges unless I manually call Reload

Is there a way to tell the EF context that the reference field is generated on the client side but at the same time can be re-generated by the database, and if that happens, refresh the entity in memory automatically during the SaveChanges?

In other words I'm looking for something similar to ValueGeneratedOnAddOrUpdate but saving the value coming the client side first.

@ajcvickers
Copy link
Member

Putting this on the backlog to consider supporting store-generated values that are both written to the database and then also read back from the database in the same command,

@ajcvickers ajcvickers changed the title Value generated on the client side, that can be changed by the database on add or update Support store-generated values that are both written to and also read back from the database in the same command Nov 7, 2020
@ajcvickers ajcvickers added this to the Backlog milestone Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants