Skip to content

Instantly share code, notes, and snippets.

@rafaelpadovezi
Created March 12, 2021 20:37
Show Gist options
  • Save rafaelpadovezi/74c104a5379541accdf12dd33e9e3d0d to your computer and use it in GitHub Desktop.
Save rafaelpadovezi/74c104a5379541accdf12dd33e9e3d0d to your computer and use it in GitHub Desktop.
Add entities - explicity transaction
var employee = new Employee
{
Name = "John Doe",
Entries = new List<TimeEntry>
{
new TimeEntry
{
Start = TimeSpan.FromHours(8),
End = TimeSpan.FromHours(12)
}
}
};
context.Add(employee);
using var transaction = context.Database.BeginTransaction();
context.SaveChanges();
transaction.Commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment