I use .Net 6 and when I want to run my first migration, I get this error:
Value cannot be null. (Parameter 'connectionString')
My appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=Solardb;integrated security=SSPI"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
And this is my Configuration method in program.cs:
builder.Services.AddDbContext<SolarDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("ConnectionStrings")));