private void SetupDb(out DbContextOptions <EmployeeShiftContext> options) { options = DbContextOptions(); var shifts = new List <Shift> { new Shift { ShiftID = 1, ShiftName = "First Shift", ShiftStart = new DateTime(2018, 1, 1, 8, 0, 0), ShiftEnd = new DateTime(2018, 1, 1, 16, 0, 0) }, new Shift { ShiftID = 2, ShiftName = "Second Shift", ShiftStart = new DateTime(2018, 1, 2, 8, 0, 0), ShiftEnd = new DateTime(2018, 1, 1, 16, 0, 0) }, new Shift { ShiftID = 3, ShiftName = "Fourth Shift", ShiftStart = new DateTime(2018, 1, 1, 7, 0, 0), ShiftEnd = new DateTime(2018, 1, 1, 16, 0, 0) }, new Shift { ShiftID = 4, ShiftName = "Fifth Shift", ShiftStart = new DateTime(2018, 2, 1, 8, 0, 0), ShiftEnd = new DateTime(2018, 1, 1, 16, 0, 0) } }; var employees = new List <Employee> { new Employee { EmployeeID = 1, FirstName = "FirstName", Surname = "Surname" }, new Employee { EmployeeID = 2, FirstName = "First Name", Surname = "Sur Name" } }; var employeeWorkShifts = new List <EmployeeWorksShift> { new EmployeeWorksShift { ShiftID = 1, EmployeeID = 1 }, new EmployeeWorksShift { ShiftID = 2, EmployeeID = 2 }, new EmployeeWorksShift { ShiftID = 3, EmployeeID = 1 }, new EmployeeWorksShift { ShiftID = 4, EmployeeID = 1 }, }; using (var context = new EmployeeShiftContext(options)) { if (context.Employees.Any()) { return; } context.AddRange(employees); context.AddRange(employeeWorkShifts); context.AddRange(shifts); context.SaveChanges(); } }