Exemplo n.º 1
0
        public static async Task Seed(ISchoolAppDbContext context)
        {
            var entity = new SchoolDto()
            {
                id   = Guid.Parse("eae2acee-5b9c-4f4b-a477-8668fee43fea"),
                name = "Seeded School, For Testing"
            };

            if (context.Schools.Any(x => x.id == entity.id))
            {
                return;
            }
            context.Schools.Add(entity);
            await context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public static async Task Seed(ISchoolAppDbContext context)
        {
            var entities = GetEntities();

            foreach (var entity in entities)
            {
                if (context.Teachers.Any(x => x.id == entity.id))
                {
                    continue;
                }

                context.Teachers.Add(entity);
            }

            await context.SaveChangesAsync();
        }