From d258ea461556bb75ef418d47c9d6817572a7db67 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:03:47 +0100 Subject: [PATCH 1/9] Installazione libreria SQLite --- PizzaExpress/PizzaExpress.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj index cab5d05..1573d0b 100644 --- a/PizzaExpress/PizzaExpress.csproj +++ b/PizzaExpress/PizzaExpress.csproj @@ -9,6 +9,7 @@ + From c69cc287b698b9f531225998499a28add6cb2073 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:05:05 +0100 Subject: [PATCH 2/9] Aggiornamento librerie --- PizzaExpress/PizzaExpress.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj index 1573d0b..2ea6207 100644 --- a/PizzaExpress/PizzaExpress.csproj +++ b/PizzaExpress/PizzaExpress.csproj @@ -11,8 +11,8 @@ - - + + From 6dcdbea46bfa8adaa8c53f76ad5e7a02ef5ac359 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:19:54 +0100 Subject: [PATCH 3/9] Replaced Microsoft.Data.Sqlite with Microsoft.EntityFrameworkCore.Sqlite --- PizzaExpress/PizzaExpress.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj index 2ea6207..c168e04 100644 --- a/PizzaExpress/PizzaExpress.csproj +++ b/PizzaExpress/PizzaExpress.csproj @@ -9,8 +9,8 @@ - + From e04b85fa30ab5a9db5126f6bb406ffe8f73a50f4 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:24:00 +0100 Subject: [PATCH 4/9] Rimozione libreria InMemory e cambio versione libreria Sqlite --- PizzaExpress/PizzaExpress.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PizzaExpress/PizzaExpress.csproj b/PizzaExpress/PizzaExpress.csproj index c168e04..d4b6e50 100644 --- a/PizzaExpress/PizzaExpress.csproj +++ b/PizzaExpress/PizzaExpress.csproj @@ -9,8 +9,7 @@ - - + From 0eecf829e17c92fb4e6d13c625b7612856ff371b Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:37:53 +0100 Subject: [PATCH 5/9] Aggiunta database a gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cea887d..5a7fddf 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 From 366fad3241cc6cc4f7590ff39d717fb2aa8817f7 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:38:11 +0100 Subject: [PATCH 6/9] Implementazione database SQLite in Program.cs --- PizzaExpress/Program.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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(); } } From 07044d6156fb32fba9c90c461d79875a6f1e59a8 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:45:45 +0100 Subject: [PATCH 7/9] Aggiustamento ignore database in gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5a7fddf..a10f6df 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,4 @@ TestResult.xml nunit-*.xml .vs/ -pizza.db \ No newline at end of file +pizza.db* \ No newline at end of file From c8e5c403fb91a0459c20ba76a16d7be9d31a0202 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:47:00 +0100 Subject: [PATCH 8/9] =?UTF-8?q?Rimozione=20creazione=20entry=20automatica?= =?UTF-8?q?=20all'esecuzione=20(pu=C3=B2=20creare=20problemi)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PizzaExpress/Data/PizzaContext.cs | 8 -------- 1 file changed, 8 deletions(-) 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(); } } } From e5a6e81881c3bcc9284a85726d1e7f24dc8b1f07 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 26 Nov 2025 08:50:11 +0100 Subject: [PATCH 9/9] Aggiunta database di esempio --- PizzaExpress/pizza.example.db | Bin 0 -> 12288 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 PizzaExpress/pizza.example.db diff --git a/PizzaExpress/pizza.example.db b/PizzaExpress/pizza.example.db new file mode 100644 index 0000000000000000000000000000000000000000..812af9d3b26fca60d05300f51ae56ae771115ea9 GIT binary patch literal 12288 zcmeI&Jxjwt7zgmnr6?9^)DBtCxL8_>P>ZXv91@$RF-^fvCDu~|ZDW&k$)+F958-!k z6db*TcCd?^i2NV!CHLIjGyJxL46f}k73@BWXFs5Fv~;oS|*APTv{$o+?{x(;&SE9XZZ*oFF00Izz00bZa0SG_<0uX=z z1R(Hd1rF2_IjVMor#PHU!YB#OnkW0TL=LNN93_)*nWj-&rj$I@3*v`I5r=7T+HB|V oe?|KsvLPS<0SG_<0uX=z1Rwwb2tWV=5cp35JBq3+#ZLw57yOrPR{#J2 literal 0 HcmV?d00001