// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Actividades_ComplementariasContext context) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Initialize(context); }
public static void Initialize(Actividades_ComplementariasContext context) { context.Database.EnsureCreated(); if (context.Alumnos.Any()) { return; } { var Alumnos = new Alumnos[] { new Alumnos { }, }; foreach (Alumnos a in Alumnos) { context.Alumnos.Add(a); } context.SaveChanges(); } }