0
I am trying to add the add-Migration in my solution but always happens the following error "Value cannot be null (Parameter 'connectionString')"
but my connection string is correct in appsettings.json
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDbContext<SimCoContext>(optBuilder =>
optBuilder.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));
}
Appsettings.json
{
"ConnectionsStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Pooling=true;User ID=postgres;Password=admin;Database=SimCo;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
Choose to put the code instead of the image when placing code. I believe it is misspelled in line 2 the Connectionstring
– Vainer Cesario
Probably your error is in the Startup class where you indicate the connection string in the configure service method you must indicate "Defaultconnection".
– Jersonb