I wanted to confirm If this is the best way to handle EF6 transactions in .NET API. So if the API changes only a single Entity for example update potato count in user owned potatos. I do not need to enclose it with
using (var dbContextTransaction = context.Database.BeginTransaction()) {}
because the EF will not commit the changes if it can't. But if the single API endpoint updates multiple Entities for expl. API endpoint createSoup() which removes multiple vegitables from user and creates a new entity soup for a usse. Then I do need enclose it with the mentioned statement in case it removes the vegitables, but was unable to create the soup entity and vice versa. Is there no other way? because it seems a little overkill to put all the api endpoint function (which edit mulptile entities) inside this statement.
context.SaveChanges();do you have? If you have a single call, the you don't need to do anything.