Ejemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcTitleContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcTitleContext> >()))
            {
                if (context.User.Any())
                {
                    return;
                }

                var user = new User
                {
                    Name  = "Ryan",
                    Email = "*****@*****.**"
                };

                context.User.Add(user);

                context.SaveChanges();

                if (context.Title.Any())
                {
                    return;
                }

                var csvImporter = new CsvImporter();

                csvImporter.ImportTitles(context);
            }
        }