• 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();
                    }
                }
            }
  • 相关阅读:
    分页
    用于dbnull的数据转换。因为用convert.to无法转换dbnull类型
    sqldbhelper
    sql 去重
    wcf 双工
    WCF使用泛型方法的问题
    wpf 查找页面的所有TextBox
    WebService流行框架之Axis和CXF
    Hibernate SQL方言 (hibernate.dialect)
    Hibernate联合主键映射
  • 原文地址:https://www.cnblogs.com/shiningrise/p/7592069.html
Copyright © 2020-2023  润新知