Пример #1
0
        public WebFrequenciesDbContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <WebFrequenciesDbContext>();

            var config            = LoadConfiguration.Configure().Build();
            var connectionStrings = config[$"{nameof(ConnectionStrings)}:{nameof(ConnectionStrings.HtmlAnalysisDb)}"];

            optionsBuilder.UseSqlServer(connectionStrings);

            return(new WebFrequenciesDbContext(optionsBuilder.Options));
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var config = LoadConfiguration.Configure().Build();

            var host = BuildWebHostBuilder(args, config);

            using (var scope = host.Services.CreateScope())
            {
                var context = scope.ServiceProvider.GetService <WebFrequenciesDbContext>();

                context.Database.Migrate();
            }

            host.Run();
        }
Пример #3
0
 public static IHost BuildWebHostBuilder(string[] args, IConfiguration config)
 {
     return(Host.CreateDefaultBuilder(args)
            .UseServiceProviderFactory(new AutofacServiceProviderFactory())
            .ConfigureAppConfiguration(configBuilder =>
     {
         configBuilder = LoadConfiguration.Configure();
     })
            .ConfigureWebHostDefaults(webHostBuilder =>
     {
         webHostBuilder
         .UseConfiguration(config)
         .UseStartup <Startup>();
     })
            .Build());
 }