小编use*_*291的帖子

.Net Core将连接字符串传递给DBContext类

刚开始使用.Net Core并将连接字符串信息传递给Context控制台项目.

我有4个项目,使用.Net Core创建.

  1. MVC
  2. 服务层
  3. 域层
  4. 数据层

在MVC项目中,我有Startup.cs文件,我正在阅读appsettings.json文件

    public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddMvc();

            // Add appsettings
            services.Configure<AppSettingsConfig>(Configuration.GetSection("AppSettings")); 
}


public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();

        if (env.IsDevelopment())
        {
            // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
            builder.AddApplicationInsightsSettings(developerMode: true);
        }
        Configuration = builder.Build();
    }
Run Code Online (Sandbox Code Playgroud)

在我的第4个项目(Data Layer)中,有哪个Console Project并且有以下DBContext类.这个项目没有像我MVC项目那样的Startup.cs.不是由VS 2015默认创建的.

public class MyDWContext : DbContext …
Run Code Online (Sandbox Code Playgroud)

asp.net-core

3
推荐指数
1
解决办法
5064
查看次数

Javascript:找到最接近的号码

我想在javascript中找到舍入的最接近的数字,例如

10 - > 10

11 - > 10

12 - > 10

13 - > 15

16 - > 15

17 - > 15

18 - > 20

19 - > 20

20 - > 20

javascript

-5
推荐指数
1
解决办法
325
查看次数

标签 统计

asp.net-core ×1

javascript ×1