public static void Initializate(dvdCollectionContext context) { context.Database.EnsureCreated(); //c rea un Bd si no exite if (context.filmGeneres.Any()) { return; //la base de dats ya tiene datos } // arreglo de tipo film generes var FilmGeneres = new FilmGeneres[] { new FilmGeneres { GenreDesc = "Action" }, new FilmGeneres { GenreDesc = "Aventure" }, new FilmGeneres { GenreDesc = "Animation" }, new FilmGeneres { GenreDesc = "biograpy" }, new FilmGeneres { GenreDesc = "Comedy" }, new FilmGeneres { GenreDesc = "Crime" } new FilmGeneres { GenreDesc = "Drama" } new FilmGeneres { GenreDesc = "Family" } new FilmGeneres { GenreDesc = "Fantasy" } new FilmGeneres { GenreDesc = "History" } }; foreach (FilmGeneres g in FilmGeneres) { context.filmGeneres.add(g); } context.SaveChanges(); } }
public static void Initializate(dvdCollectionContext context) { context.Database.EnsureCreated(); if (context.FilmGeneres.Any()) { return; // ya tiene datos } // arreglo de tipo de filgeneres var filmGeneres = new FilmGeneres[] { new FilmGeneres { GenreDesc = "Actions" }, new FilmGeneres { GenreDesc = "Aventure" }, new FilmGeneres { GenreDesc = "Animation" }, new FilmGeneres { GenreDesc = "Comedy" }, new FilmGeneres { GenreDesc = "Drama" }, new FilmGeneres { GenreDesc = "Family" } }; // pasar el arreglo a la tabla foreach (var i in filmGeneres) { //context.FilmGeneres.add(i); } // grbar los adatos en bd fisica context.SaveChanges(); }