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

后端 未结 22 1935
时光取名叫无心
时光取名叫无心 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:22

    This worked flawlessly for me:

    public IConfiguration Configuration;
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext(options => 
                //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
                options.UseSqlServer("Server=serverAddress; Database=dbName; user=username; password=pswd"));
    }
    

    The commented part is just as reference where to replace.

提交回复
热议问题