public void Setup() { var builder = new DbContextOptionsBuilder <BikesContext>().UseSqlServer(ConnectionString); _context = new BikesContext(builder.Options); _service = new SalesPersonsService(_context); using (var transaction = _context.Database.BeginTransaction()) { _context.SalesPersons.Add(new SalesPerson { Id = 1, FirstName = "Harecore", LastName = "Salesman", Address = "1 Street Ln", Phone = "321-321-4321", TerminationDate = DateTime.MaxValue, StartDate = DateTime.MinValue, Manager = "Joe" }); _context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [SalesPersons] ON"); _context.SaveChanges(); _context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [SalesPersons] OFF"); transaction.Commit(); } }
public SalesPersonsController(SalesPersonsService service) { _service = service; }