soraraso42 / learning-journal

0 stars 0 forks source link

configure asp.net core app - add services #51

Open soraraso42 opened 2 months ago

soraraso42 commented 2 months ago

` // 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