diff --git a/.gitignore b/.gitignore
index cea887d..a10f6df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,4 +53,5 @@ CodeCoverage/
TestResult.xml
nunit-*.xml
-.vs/
\ No newline at end of file
+.vs/
+pizza.db*
\ No newline at end of file
diff --git a/PizzaExpress/Data/PizzaContext.cs b/PizzaExpress/Data/PizzaContext.cs
index eadef56..7b0503c 100644
--- a/PizzaExpress/Data/PizzaContext.cs
+++ b/PizzaExpress/Data/PizzaContext.cs
@@ -18,14 +18,6 @@ namespace PizzaExpress.Data
public static void Initialize(PizzaContext ctx)
{
if (ctx.Pizze.Any()) return;
-
- ctx.Pizze.AddRange(
- new Pizza { Id = 1, Nome = "Margherita", Prezzo = 4.50m },
- new Pizza { Id = 2, Nome = "Prosciutto", Prezzo = 5.00m },
- new Pizza { Id = 3, Nome = "Capricciosa", Prezzo = 7.00m }
- );
-
- ctx.SaveChanges();
}
}
}
diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj
index cab5d05..d4b6e50 100644
--- a/PizzaExpress/PizzaExpress.csproj
+++ b/PizzaExpress/PizzaExpress.csproj
@@ -9,9 +9,9 @@
-
-
-
+
+
+
diff --git a/PizzaExpress/Program.cs b/PizzaExpress/Program.cs
index 50ce49a..03e1f19 100644
--- a/PizzaExpress/Program.cs
+++ b/PizzaExpress/Program.cs
@@ -30,9 +30,10 @@ namespace PizzaExpress
builder.Services.AddControllers()
.AddXmlSerializerFormatters();
- // DB in memory perch� siamo froci
+ // Creazione del contesto con DB SQLite
builder.Services.AddDbContext(opt =>
- opt.UseInMemoryDatabase("dbpizze"));
+ opt.UseSqlite("Data Source=pizza.db"));
+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
@@ -40,9 +41,11 @@ namespace PizzaExpress
var app = builder.Build();
- using (var porcoidddioooo = app.Services.CreateScope())
+ using (var scope = app.Services.CreateScope())
{
- var ctx = porcoidddioooo.ServiceProvider.GetRequiredService();
+ var ctx = scope.ServiceProvider.GetRequiredService();
+ // Crea il DB e le tabelle basate sul modello se non esistono (no migrations)
+ ctx.Database.EnsureCreated();
SeedData.Initialize(ctx);
}
@@ -56,6 +59,8 @@ namespace PizzaExpress
app.MapControllers();
+
+
app.Run();
}
}
diff --git a/PizzaExpress/pizza.example.db b/PizzaExpress/pizza.example.db
new file mode 100644
index 0000000..812af9d
Binary files /dev/null and b/PizzaExpress/pizza.example.db differ