Running "dotnet ef migrations add InitialCreate; dotnet ef database update" Will likely fail. Below is some tips on actually connecting
In appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"PizzaDb": "Server=localhost;Database=PizzaDb;User=sa;Password=Password%1#29;Integrated Security=true"
}
}
You have to add the ConnectionSring part. The database is called PizzaDb and for simplicity i named the connection string PizzaDb but it could have been something else note i make a user account sa, and i se ta password. You must set Integrated Security to true (have no idea what that does) Assuming you're doing minimum apis (.net 6 and newer) go to Program.cs and look at your connection string var builder = WebApplication.CreateBuilder(args); var connectionString = builder.Configuration.GetConnectionString("PizzaDb") ?? "Data Source=Pizzas.db"; //Connection string first req. for using a db. Note howGetConnectionString is looking for PizzaDb, which you have to set in appsettings.json