Implement initial product management with Entity Framework Core #3

This commit is contained in:
Marek Lesko
2025-07-27 16:03:55 +00:00
parent 5f921e5a2c
commit e969008873
9 changed files with 272 additions and 22 deletions

View File

@@ -6,17 +6,19 @@ using Microsoft.Identity.Web.Resource;
namespace Api
{
public class Program
using Microsoft.EntityFrameworkCore;
using Api.Models;
public static class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
//builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
// .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));
builder.Services.AddControllers();
// Add DbContext with SQL Server
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
@@ -24,19 +26,14 @@ namespace Api
var app = builder.Build();
// Configure the HTTP request pipeline.
// if (app.Environment.IsDevelopment())
// {
app.UseSwagger();
app.UseSwaggerUI();
// }
app.UseSwagger();
app.UseSwaggerUI();
if (!app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}
// app.UseAuthorization();
app.MapControllers();
app.Run();