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

EF Framework - Temporal tables Race conditions last update not stored #2119

Closed
vsfeedback opened this issue May 31, 2023 · 1 comment
Closed

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


I am developing an ASP.NET webAPI application using .NET Framework 4.8. In the database, I am using the Temporal tables features in a SQL Server 2017 to track the changes of the stored records. For data access, I am using Entity Framework as an ORM. This seems to work fine, however, if I update a record, and directly afterwards delete the record using the code below:

_var recordForDelete = await _dbContext.record.FirstOrDefaultAsync(x => x.ID == id);

recordForDelete.LastModifiedBy = (int)SystemActions.System;

await _dbContext.SaveChangesAsync();

_dbContext.record.Remove(recordForDelete);

await dbContext.SaveChangesAsync();

The last update performed is not captured in the system versioning tables, the record is directly marked as deleted (by setting the system end time) without the last update. It seems to be some sort of race condition, as adding a Task Delay between the two calls to _dbContext.SaveChangesAsync() solves the issue. I also tried to change to _dbContext.SaveChanges() but this didn't solve the problem. Any recommendations on how to solve this issue.?


Original Comments

Feedback Bot on 9/28/2022, 08:40 AM:

(private comment, text removed)

Feedback Bot on 1/5/2023, 06:31 AM:

(private comment, text removed)


Original Solutions

(no solutions)

@ajcvickers
Copy link
Member

This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants