// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, BlogNoticiasContext 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(BlogNoticiasContext context) { context.Database.EnsureCreated(); if (context.Publicacion.Any()) { return; } var publicacion = new Publicacion[] { new Publicacion { Titulo = "curso de .NET", Subtitulo = "c#, core 2, javascript", Autor = "Mauro Icardi", Fecha = new DateTime(2018, 06, 10), Cuerpo = "mi primer blog" }, new Publicacion { Titulo = "curso 111mil", Subtitulo = "java", Autor = "Mauro Icardi", Fecha = new DateTime(2018, 06, 10), Cuerpo = "Mi primer blog" } }; foreach (Publicacion c in publicacion) { context.Publicacion.Add(c); } context.SaveChanges(); }
public HomeController(BlogNoticiasContext context, IConfiguration iconfiguration) { _context = context; _iconfiguration = iconfiguration; }