SHARE
TWEET

Untitled

Ortund Jul 4th, 2014 168 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void Seed()
  2. {
  3.     if (!Roles.Any())
  4.     {
  5.         //Role r = new Role();
  6.         //r.RoleName = "User";
  7.         List<Role> roles = new List<Role>
  8.         {
  9.             new Role { RoleName = "Admin" },
  10.             new Role { RoleName = "User" }
  11.         };
  12.         foreach (Role r in roles)
  13.         {
  14.             Roles.Add(r);
  15.         }
  16.         SaveChanges();
  17.     }
  18.     if (!Users.Any())
  19.     {
  20.         User u = new User();
  21.         u.EmailAddress = "this@that.com";
  22.         u.Username = "ortund";
  23.         u.Password = Hashing.CreateHash("P455w@rd");
  24.         u.Role = Roles.Single(r => r.PKey == 1);
  25.         u.PasswordReset = false;
  26.         u.PasswordResetKey = Hashing.CreateKey();
  27.  
  28.         Users.Add(u);
  29.         SaveChanges();
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top