Asp.net 值不能为null。参数名称:connectionString

Asp.net 值不能为null。参数名称:connectionString,asp.net,asp.net-core-2.0,Asp.net,Asp.net Core 2.0,所以我一直在stackoverflow周围检查与我的问题相关的所有问题,所有问题都得到了解决,但我仍然得到了相同的错误 值不能为null。 参数名称:connectionString 是运行添加迁移“初始迁移”时的结果 这是我在Startup.cs上的代码 public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguratio

所以我一直在stackoverflow周围检查与我的问题相关的所有问题,所有问题都得到了解决,但我仍然得到了相同的错误

值不能为null。 参数名称:connectionString

是运行添加迁移“初始迁移”时的结果

这是我在Startup.cs上的代码

public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        services.AddDbContext<LibraryContext>(options 
            => options.UseSqlServer(Configuration.GetConnectionString("LibraryConnection")));
    }

    // 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();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
请注意,我有一个LibraryData项目(这是另一个项目),该类由一个名为LibraryContext的类组成

public class : DbContext
{
    public LibraryContext(DbContextOptions options) : base(options) { }

    public DbSet<Patron> Patrons { get; set; }
}   
公共类:DbContext
{
公共LibraryContext(DbContextOptions选项):基本(选项){}
公共数据库集用户{get;set;}
}   

我似乎找不到我做错了什么,因为我已经根据网上的材料和问题做了所有的事情!有人能帮我一下吗?

我想你的appsettings中有一个输入错误。json ConnectionString应该是ConnectionString

{
“连接字符串”:{
“LibraryConnection”:“服务器(localdb)\\MSSQLLocalDB;数据库=库\u开发;可信\u连接=真;MultipleActiveResultSets=真”
},
“日志记录”:{
“包含范围”:错误,
“日志级别”:{
“默认值”:“警告”
}
}

}
我认为您在appsettings中输入了一个错误。json ConnectionString应该是ConnectionString

{
“连接字符串”:{
“LibraryConnection”:“服务器(localdb)\\MSSQLLocalDB;数据库=库\u开发;可信\u连接=真;MultipleActiveResultSets=真”
},
“日志记录”:{
“包含范围”:错误,
“日志级别”:{
“默认值”:“警告”
}
}

}
我不知道你是怎么看的!你是我的英雄。非常感谢。我不知道你是怎么看的!你是我的英雄。非常感谢你。
public class : DbContext
{
    public LibraryContext(DbContextOptions options) : base(options) { }

    public DbSet<Patron> Patrons { get; set; }
}