Esempio n. 1
0
        public async static Task Initialize(RepositoryContext context)
        {
            await context.Database.MigrateAsync();

            var userCount = await context.Users.CountAsync().ConfigureAwait(false);

            if (userCount == 0)
            {
                context.Users.Add(new Models.User()
                {
                    Login    = "******",
                    Password = "******"
                });
            }

            await context.SaveChangesAsync().ConfigureAwait(false);
        }
        public async static Task Initialize(RepositoryContext context)
        {
            await context.Database.MigrateAsync();

            var userCount = await context.Users.CountAsync().ConfigureAwait(false);

            if (userCount == 0)
            {
                context.Users.Add(new Models.User()
                {
                    Login    = "******",
                    Password = "******",
                    isAdmin  = true
                });
                context.Posts.Add(new Models.Post()
                {
                    Header      = "Учетная запись админа",
                    Body        = "Login/Password: admin/admin",
                    CreatedDate = DateTime.Now
                });

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }