Implemetato databese locale con EntityFramework
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using System.Data;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SteUp.Data.LocalDb;
|
||||
using SteUp.Data.LocalDb.EntityServices;
|
||||
using SteUp.Maui.Core.Services;
|
||||
using SteUp.Maui.Core.System;
|
||||
using SteUp.Maui.Core.System.Network;
|
||||
@@ -6,6 +10,7 @@ using SteUp.Shared.Core.Data;
|
||||
using SteUp.Shared.Core.Data.Contracts;
|
||||
using SteUp.Shared.Core.Interface;
|
||||
using SteUp.Shared.Core.Interface.IntegryApi;
|
||||
using SteUp.Shared.Core.Interface.LocalDb;
|
||||
using SteUp.Shared.Core.Interface.System;
|
||||
using SteUp.Shared.Core.Interface.System.Network;
|
||||
using SteUp.Shared.Core.Services;
|
||||
@@ -40,4 +45,16 @@ public static class CoreModule
|
||||
builder.Services.AddScoped<AuthenticationStateProvider>(provider =>
|
||||
provider.GetRequiredService<AppAuthenticationStateProvider>());
|
||||
}
|
||||
|
||||
public static void RegisterDbServices(this MauiAppBuilder builder)
|
||||
{
|
||||
builder.Services.AddSingleton<IDbPathProvider, DbPathProvider>();
|
||||
builder.Services.AddDbContext<AppDbContext>((sp, options) =>
|
||||
{
|
||||
var dbPath = sp.GetRequiredService<IDbPathProvider>().GetDbPath();
|
||||
options.UseSqlite($"Filename={dbPath}");
|
||||
});
|
||||
builder.Services.AddSingleton<IDbInitializer, DbInitializer>();
|
||||
builder.Services.AddSingleton<IIspezioniService, IspezioniService>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user