I have a bit stupid question, but I didn't find an answer.
Is there any difference between a single call to SaveChanges() and a single call to SaveChanges() inside a transaction? (I'm using Entity Framework in .net core 5 application)
I want to create a record in one table and update data in another one.
For example, it would be:
users.Password = "..."
var passwordReset = new PasswordReset(...)
_context.Add(passwordReset);
_context.SaveChanges();
And with transaction:
using (var transaction = _context.Database.BeginTransaction())
{
users.Password = "..."
var passwordReset = new PasswordReset(...)
_context.Add(passwordReset);
_context.SaveChanges();
transaction.Commit();
}
I want to ensure, that two queries will complete successfully but I don't know which option would be the best for me.
Thanks in advance