zoukankan      html  css  js  c++  java
  • efcore数据库自动生成

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
            {
                loggerFactory.ConfigureNLog("nlog.config");
                loggerFactory.AddNLog();
    
                app.UseRequestIPMiddleware();
    
                InitializeNetCoreBBSDatabase(app.ApplicationServices);
                app.UseDeveloperExceptionPage();
    
                app.UseStaticFiles();
                app.UseAuthentication();
                app.UseStatusCodePages();
    
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "areaRoute",
                        template: "{area:exists}/{controller}/{action}",
                        defaults: new { action = "Index" });
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");
                });
            }
    
            private void InitializeNetCoreBBSDatabase(IServiceProvider serviceProvider)
            {
                using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
                {
                    var db = serviceScope.ServiceProvider.GetService<DataContext>();
                    db.Database.Migrate();
                    if (db.TopicNodes.Count() == 0)
                    {
                        db.TopicNodes.AddRange(GetTopicNodes());
                        db.SaveChanges();
                    }
                }
            }
  • 相关阅读:
    JAVA课后作业
    类中创建对象的个数
    JAVA动手动脑及课后思考
    JAVA课后作业
    java课后思考
    加法
    大道至简第一章伪代码
    解决得到网络流不支持查找的方案
    row_number() over(partition by 列名1 order by 列名2 desc)的使用
    SQL中的特殊符号
  • 原文地址:https://www.cnblogs.com/shiningrise/p/7592069.html
Copyright © 2011-2022 走看看