asp.net core 2.0 - Value cannot be null. Parameter name: connectionString

后端 未结 22 1915
时光取名叫无心
时光取名叫无心 2020-12-13 10:00

I had the following error in package manager console when Add-Migration

Value cannot be null. Parameter name: connectionString

22条回答
  •  误落风尘
    2020-12-13 10:27

    I had a similar problem when I specified the ".UseContentRoot" as the current process path.

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://*:3001")
                .UseStartup()
                .UseContentRoot(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
    

    thus when running Add-Migration the process path is different from the project bin path therefore the process can't find the appsettings.json file. when I removed the ".UseContentRoot" line the migration was successful

提交回复
热议问题