Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  2. {
  3. if (env.IsDevelopment())
  4. {
  5. app.UseDeveloperExceptionPage();
  6. app.UseBrowserLink();
  7. }
  8. else
  9. {
  10. app.UseExceptionHandler("/Home/Error");
  11. }
  12.  
  13. app.UseStaticFiles();
  14.  
  15. app.UseMvc(routes =>
  16. {
  17. routes.MapRoute(
  18. name: "default",
  19. template: "{controller=Home}/{action=Index}/{id?}");
  20. });
  21.  
  22. SeedData.Seed(app);
  23. }
  24.  
  25. public static class SeedData
  26. {
  27. public static void Seed(IApplicationBuilder app)
  28. {
  29. var _dbContext= app.ApplicationServices.GetRequiredService<BlogDbContext>();
  30.  
  31. _dbContext.Database.EnsureDeleted();
  32.  
  33. _dbContext.Add<User>(new User { UserName = "Niko", Password ="123",EmailAddress="nikozhao5456@gmail.com",UserType= Models.User.Type.Visitor,RegistDate=System.DateTime.Now});
  34.  
  35. _dbContext.Add<Admin>(new Admin{EmailAddress="lovezgd888@163.com",Password="123"});
  36.  
  37. _dbContext.SaveChanges();
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement