// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SistemaUTHContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.initiliza(context); }
public static void initiliza(SistemaUTHContext context) { context.Database.EnsureCreated(); if (context.Categoria.Any()) //verificar si existen registro en la tabla { return; //regresa registros } //var categorias = new Categoria[] { new Categoria { Name = "Programacion", // Descripcion = "Desarrollo de aplicaciones",State = true} , // new Categoria{Name = "Exprecion oral y escrita",Descripcion ="Clase filosofia", // State = true } }; //foreach (Categoria c in categorias)//agrega los objetos al contexto para guardarlos en la base datos //{ // context.Categoria.Add(c); //} context.SaveChanges();//guarda el contexto }
public CategoriasController(SistemaUTHContext context) { _context = context; }
public EstudiantesController(SistemaUTHContext context) { _context = context; }