Created
March 12, 2021 20:37
-
-
Save rafaelpadovezi/74c104a5379541accdf12dd33e9e3d0d to your computer and use it in GitHub Desktop.
Add entities - explicity transaction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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