You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using our database to generate ID instead from C# code, that means. The Id of a newly created object is only visible after dbContextScope.SaveChanges() is called. However, the mapping between EF models and domain models already happened in the repository layer which is before saveChanges() been called. This leads to a result that the domain object returned by the add method do not have the ID.
How can I get around this issue?
Thanks,
Chenhao Gao
The text was updated successfully, but these errors were encountered:
chaoscn
changed the title
Suggestions: how to retrieve ID generated after saveChanges()
Suggestions: how to retrieve ID generated by DB after saveChanges()
Nov 19, 2018
I am struggling with the exact same issue as well. I noticed in the demo you assign a new Guid to the User Id within the UserCreationSpec which allows you to query based on this Id once created. However, if you let the database generate the ID how do I know which ID to use to query?
I am having the same issue. Are we supposed to use the AmbientDbContextLocator to grab the dbcontext and then call savechanges from within the repository?
What implications does that have on the outer transaction?
Hi,
We are using our database to generate ID instead from C# code, that means. The Id of a newly created object is only visible after dbContextScope.SaveChanges() is called. However, the mapping between EF models and domain models already happened in the repository layer which is before saveChanges() been called. This leads to a result that the domain object returned by the add method do not have the ID.
How can I get around this issue?
Thanks,
Chenhao Gao
The text was updated successfully, but these errors were encountered: