public static void Initialize(FormulaOneDbContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //already initialized if (!context.Teams.Any()) { var teams = new Team[] { new Team { Name = "Scuderia Ferrari", YearOfFoundation = 1929, AttainedWorldChampionships = 15, PaidEntryFee = true }, new Team { Name = "Red Bull Racing", YearOfFoundation = 2004, AttainedWorldChampionships = 4, PaidEntryFee = true }, new Team { Name = "Mercedes-AMG Petronas", YearOfFoundation = 2010, AttainedWorldChampionships = 8, PaidEntryFee = true }, new Team { Name = "McLaren", YearOfFoundation = 1963, AttainedWorldChampionships = 12, PaidEntryFee = true } }; foreach (Team t in teams) { context.Teams.Add(t); } context.SaveChanges(); } }
public DriversController(FormulaOneDbContext dbContext) { _dbContext = dbContext; }
public TeamRepository(FormulaOneDbContext DbContext) { db = DbContext; }