public static void Initializer(IServiceProvider serviceProvider) { using (var context = new RazorPageMovieContext(serviceProvider.GetRequiredService <DbContextOptions <RazorPageMovieContext> >())) { //look for any movies if (context.Movie.Any()) { return;//Db has been seeded } context.Movie.AddRange( new Movie { Title = "When harry met sally", ReleaseDate = DateTime.Parse("1980-02-12"), Genre = "Romantic", Price = 7.99M, Rating = "r" }, new Movie { Title = "John Wick", ReleaseDate = DateTime.Parse("2017-01-12"), Genre = "Comedy Action Adventures", Price = 12M, Rating = "r" }, new Movie { Title = "John Wick-Chapter-2", ReleaseDate = DateTime.Parse("2018-02-12"), Price = 30M, Rating = "r" }, new Movie { Title = "John Wick-Chapter-3", ReleaseDate = DateTime.Parse("2019-09-09"), Price = 60M, Rating = "r" }, new Movie { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-2-23"), Price = 8.99M, Rating = "r" } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPageMovieContext(serviceProvider .GetRequiredService <DbContextOptions <RazorPageMovieContext> >())) { //look for any movies if (context.Movies.Any()) { return; // DB has been seed } context.Movies.AddRange( new Movies { Title = "When Harry Met Sally", ReleaseDate = DateTime.Parse("1989-2-12"), Genre = "Romantic Comedy", Price = 7.99M, Rating = "R" }, new Movies { Title = "Ghostbusters ", ReleaseDate = DateTime.Parse("1984-3-13"), Genre = "Comedy", Price = 8.99M, Rating = "R" }, new Movies { Title = "Ghostbusters 2", ReleaseDate = DateTime.Parse("1986-2-23"), Genre = "Comedy", Price = 9.99M, Rating = "R" }, new Movies { Title = "Rio Bravo", ReleaseDate = DateTime.Parse("1959-4-15"), Genre = "Western", Price = 3.99M, Rating = "R" } ); context.SaveChanges(); } }
public CreateModel(RazorPageMovie.Models.RazorPageMovieContext context) { _context = context; }
public DetailsModel(RazorPageMovie.Models.RazorPageMovieContext context) { _context = context; }
public IndexModel(RazorPageMovie.Models.RazorPageMovieContext context) { _context = context; }
public EditModel(RazorPageMovie.Models.RazorPageMovieContext context) { _context = context; }