Exemplo n.º 1
0
        public async Task SeedAsync()
        {
            var users   = _userSeeder.GetDataToSeed();
            var ids     = users.Select(x => x.Id);
            var existed = await _noteMeContext.Users.Where(x => ids.Any(s => s == x.Id)).ToListAsync();

            var toInsert = users.Where(x => !existed.Any(s => s.Id == x.Id));

            await _noteMeContext.AddRangeAsync(toInsert);

            await _noteMeContext.SaveChangesAsync();
        }