Пример #1
0
        /// <summary>
        /// Handle
        /// </summary>
        /// <returns></returns>
        public Response Handle()
        {
            _query.Query(_dbContext).All().ForEach((connection) =>
            {
                var optionBuilder = new DbContextOptionsBuilder <TenantDbContext>();
                optionBuilder.UseSqlServer(connection.ConnectionString);

                var dbContext = new TenantDbContext(optionBuilder.Options);
                RelationalDatabaseFacadeExtensions.Migrate(dbContext.Database);
            });

            return(new Response());
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();

            // Run migrations
            Console.WriteLine("Running migrations");
            using (var db = new PsContext())
            {
                RelationalDatabaseFacadeExtensions.Migrate(db.Database);
            }
        }
Пример #3
0
        // TODO: Refactor this to work like the unit tests now that I know more about
        //       how to make the DI work.
        public void Run()
        {
            Console.WriteLine("Welcome to Gthx");

            // Just to get some output from Azure
            Trace.TraceError("Gthx running");

            _logger.LogInformation($"irc client is {_ircClient}");

            var context = _services.GetRequiredService <GthxDataContext>();

            RelationalDatabaseFacadeExtensions.Migrate(context.Database);
            var gthx = _services.GetRequiredService <GthxBot>();

            var done = false;

            while (!done)
            {
#if false //DEBUG
                Console.Write("command> ");
                try
                {
                    var input = Console.ReadLine();
                    if (input == null || input == "quit")
                    {
                        done = true;
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Exception in IrcBot program");
                    done = true;
                }
#else
                Thread.Sleep(5000);
#endif
            }
        }
 public UserContext(DbContextOptions <UserContext> options) : base((DbContextOptions)options)
 {
     RelationalDatabaseFacadeExtensions.Migrate(Database);
 }