Exemplo n.º 1
0
        public async Task SeedEverything(IdentityDbContext context)
        {
            if (appSettings.ApplyDbMigrations)
            {
                context.Database.Migrate();
            }
            else
            {
                context.Database.EnsureCreated();
            }

            //Seed Data Functions
            await SeedUser(context);
        }
Exemplo n.º 2
0
        public async Task SeedUser(IdentityDbContext context)
        {
            var password = new PasswordHasher("123456");

            var userList = new List <User>
            {
                new User {
                    Id = Guid.NewGuid(), CreatedBy = default(Guid), CreatedDate = DateTime.Now, Email = "*****@*****.**", IsActive = true, IsDeleted = false, Name = "admin", PasswordHash = password.Hash, PasswordSalt = password.Salt, Username = "******"
                },
                new User {
                    Id = Guid.NewGuid(), CreatedBy = default(Guid), CreatedDate = DateTime.Now, Email = "*****@*****.**", IsActive = true, IsDeleted = false, Name = "user", PasswordHash = password.Hash, PasswordSalt = password.Salt, Username = "******"
                }
            };
            await context.Users.AddRangeAsync(userList);

            context.SaveChanges();
        }
Exemplo n.º 3
0
 public IdentityDbContextInitilizer(IdentityDbContext context, IOptions <AppSettings> options)
 {
     appSettings = options.Value;
     dbContext   = context;
 }