`
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddControllersWithViews(); // this is manually added
var app = builder.Build();
var connectionString = builder.Configuration.GetConnectionString("SoraPortfolioContext") ?? throw new InvalidOperationException("Connection string 'SoraPortfolioContext' not found.");
builder.Services.AddDbContext(options =>
options.UseSqlServer(connectionString));
`
This is NOT working because the db context config should take place BEFORE build
actually build should be the last step in services setup
` // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddControllersWithViews(); // this is manually added
var app = builder.Build();
var connectionString = builder.Configuration.GetConnectionString("SoraPortfolioContext") ?? throw new InvalidOperationException("Connection string 'SoraPortfolioContext' not found."); builder.Services.AddDbContext(options =>
options.UseSqlServer(connectionString));
`
This is NOT working because the db context config should take place BEFORE build
actually build should be the last step in services setup