public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MvcBikeContext( serviceProvider.GetRequiredService < DbContextOptions <MvcBikeContext> >())) { // Look for any movies. if (context.Bike.Any()) { return; // DB has been seeded } context.Bike.AddRange( new Bike { ContractName = "Dublin", Name = "Pearse St", Address = "Pearse St", Latitude = 45.345678M, Longitude = 88.2766M, Banking = true, AvailableBikes = 67, AvailableStands = 45, Capacity = 130, Status = "OPEN", }, new Bike { ContractName = "Dublin", Name = "Mayor Street Upper", Address = "Mayor Street Upper", Latitude = 56.345M, Longitude = 35.7809M, Banking = false, AvailableBikes = 78, AvailableStands = 95, Capacity = 200, Status = "CLOSE", } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MvcBikeContext( serviceProvider.GetRequiredService < DbContextOptions <MvcBikeContext> >())) { // Look for any station. if (context.DublinBike.Any()) { return; // DB has been seeded } context.DublinBike.AddRange( new DublinBike { Number = 42, ContractName = "Dublin", Name = "SMITHFIELD NORTH", Address = "Smithfield North", Latitude = 53.349562f, Longitude = -6.278198f, Banking = true, Status = "OPEN", Available_bikes = 40, Available_stands = 10, Capacity = 50 }, new DublinBike { Number = 30, ContractName = "Dublin", Name = "PARNELL SQUARE NORTH", Address = "Parnell Square North", Latitude = 53.353462f, Longitude = -6.265305f, Banking = true, Status = "OPEN", Available_bikes = 40, Available_stands = 10, Capacity = 50 }, new DublinBike { Number = 54, ContractName = "Dublin", Name = "CLONMEL STREET", Address = "Clonmel Street", Latitude = 53.98696f, Longitude = -6.275879f, Banking = true, Status = "OPEN", Available_bikes = 40, Available_stands = 10, Capacity = 50 }, new DublinBike { Number = 48, ContractName = "Dublin", Name = "EXCISE WALK", Address = "Excise Walk", Latitude = 53.207402f, Longitude = -6.535775f, Banking = true, Status = "OPEN", Available_bikes = 40, Available_stands = 10, Capacity = 50 } ); context.SaveChanges(); } }