I use .Net 6 and when I want to run my first migration I get this error:
The value cannot be null. ('connectionString' parameter)
My appsettings.json
{
"Logging": {
"ConnectionStrings": {
"DefaultConnection": "Data Source=MSI;Initial Catalog=tiendalibro;Integrated Security=True"
},
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
And the following is my method in Program.cs
builder.Services.AddDbContext<ContextoLibreria>(options => options.UseSqlServer("DefaultConnection"));
Try overriding this method:
For this one:
On the other hand, I also see that you are putting the connection string inside the
logging
, try putting it below theAllowedHosts: "*"
:It is because you have misconfigured your appsettings.json
and on
Program.cs
fire your connection