Ejemplo n.º 1
0
        public static async Task SeedUserReports(GearContext context)
        {
            if (!await context.UserReports.AnyAsync())
            {
                var employees = await context.ApplicationUsers.ToListAsync();

                var reports = await context.Reports.ToListAsync();

                var userReports =
                    (from employee in employees
                     from report in reports
                     select new UserReport <Guid> {
                    ReportId = report.Id, UserId = employee.Id
                }).ToList();

                await context.AddRangeAsync(userReports);

                await context.SaveChangesAsync();
            }
        }