Esempio n. 1
0
 public async Task SaveChangesAsync()
 {
     if (await context.SaveChangesAsync() < 0)
     {
         throw new Exception("Cannot save changes in db.");
     }
 }
Esempio n. 2
0
        public async Task Seed()
        {
            List <User> users = UserInitializer.Seed();
            await context.AddRangeAsync(users);

            await context.SaveChangesAsync();

            List <Post>   posts   = PostInitializer.Seed(users);
            List <Friend> friends = FriendInitializer.Seed(users.Select(u => u.Id).ToArray());
            await context.AddRangeAsync(posts);

            await context.SaveChangesAsync();

            await context.AddRangeAsync(friends);

            await context.SaveChangesAsync();
        }