Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- app.UseBrowserLink();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- app.UseStaticFiles();
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- SeedData.Seed(app);
- }
- public static class SeedData
- {
- public static void Seed(IApplicationBuilder app)
- {
- var _dbContext= app.ApplicationServices.GetRequiredService<BlogDbContext>();
- _dbContext.Database.EnsureDeleted();
- _dbContext.Add<User>(new User { UserName = "Niko", Password ="123",EmailAddress="nikozhao5456@gmail.com",UserType= Models.User.Type.Visitor,RegistDate=System.DateTime.Now});
- _dbContext.Add<Admin>(new Admin{EmailAddress="lovezgd888@163.com",Password="123"});
- _dbContext.SaveChanges();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement