示例#1
0
 public void SeededData()
 {
     using (var scope = _ServiceProvider.CreateScope())
     {
         var serviceProvider = scope.ServiceProvider;
         try
         {
             DataContext dataContext = new DataContext(serviceProvider.GetRequiredService <DbContextOptions <DataContext> >());
             using (dataContext)
             {
                 new SeedTenants(dataContext).Initialize("Table_Tenants.csv");
                 new SeedRoles(dataContext).Initialize("Table_Roles.csv");
                 new SeedUser(dataContext).Initialize("Table_User.csv");
                 var  seedSuggestion = new SeedSuggestion(dataContext);
                 bool any            = seedSuggestion.Initialize("Table_Suggestion.csv");
                 new SeedVote(dataContext).Initialize("Table_Votes.csv");
                 new SeedReplies(dataContext).Initialize("Table_Replies.csv");
                 if (!any)
                 {
                     seedSuggestion.UpdateSumaries();
                 }
             }
         }
         catch (Exception ex)
         {
             var logger = _ServiceProvider.GetRequiredService <ILogger <SetupFacade> >();
             logger.LogError(ex, "An error occurred seeding the DB.");
         }
     }
 }
示例#2
0
        public void ExecuteSeed()
        {
            DataContext dataContext           = new DataContext(GetOptionBuilder().Options);
            DataContext dataContextUser       = new DataContext(GetOptionBuilder().Options);
            DataContext dataContextSuggestion = new DataContext(GetOptionBuilder().Options);

            using (dataContext)
            {
                //OJO NO AGREGA LOS DATOS DE FORMA ORDENADA, VERIFICAR LOS VOTOS DE LA SUGERENCIA
                new SeedTenants(dataContext).Initialize("Table_Tenants.csv");
                new SeedStatus(dataContext).Initialize("Table_Status.csv");
                new SeedRoles(dataContext).Initialize("Table_Roles.csv");
                new SeedUser(dataContextUser).Initialize("Table_User.csv");
                var  seedSuggestion = new SeedSuggestion(dataContextSuggestion);
                bool any            = seedSuggestion.Initialize("Table_Suggestion.csv");
                new SeedVote(dataContext).Initialize("Table_Votes.csv");
                //new SeedReplies(dataContext).Initialize("Table_Replies.csv");
                if (!any)
                {
                    seedSuggestion.UpdateSumaries();
                }
            }
        }