public static void Seed(ShutterCartContext context) { _context = context; _context.Database.EnsureCreated(); string password = "******"; var userm = new UserModel() { FirstName = "Demo-User", LastName = "Account", MiddleName = "user", EmailAddress = "*****@*****.**", Password = password }; string salt = Guid.NewGuid().ToString(); var user = new User() { FirstName = "Demo", LastName = "Admin", EmailAddress = "*****@*****.**", Password = EncryptPassword(password, salt), Salt = salt, Address = "123", ApplicationCode = Guid.NewGuid().ToString(), Channel = RegistrationChannel.IsWeb, CreatedBy = 1, DateOfBirth = DateTime.Now, Gender = 1, CreatedDate = DateTime.Now, LastLoginDate = DateTime.Now, MiddleName = "G", Mobile = "08130230146", Title = "Mr", }; user.UserName = $"{user.FirstName}.{user.LastName}{new Random().Next(1000, 24344)}@shuttercart.com"; _context.Users.Add(user); _context.SaveChanges(); // Create Role _context.Role.Add(new Role() { Name = "Administration", CreatedDate = DateTime.Now, CreatedBy = 1 }); _context.Role.Add(new Role() { Name = "Users", CreatedDate = DateTime.Now, CreatedBy = 1 }); _context.SaveChanges(); _context.UserRole.Add(new UserRole() { RoleId = 1, UserId = 1, CreatedDate = DateTime.Now, CreatedBy = 1 }); _context.SaveChanges(); }
public ShutterCartSeeder2(ShutterCartContext ctx, IHostingEnvironment environment, UserManager <UserModel> userManager) { _context = ctx; _environment = environment; _userManager = userManager; }