mirror of
https://github.com/Stefan-5422/-T5-Elektrifikatsiya.git
synced 2026-09-04 00:45:58 +02:00
🧾Whoop Whoop Database Time 😎
This commit is contained in:
@@ -6,5 +6,9 @@ namespace Elektrifikatsiya.Database
|
||||
public class DeviceManagmentDatabaseContext : DbContext
|
||||
{
|
||||
public DbSet<Device> Devices { get; set; }
|
||||
|
||||
public DeviceManagmentDatabaseContext(DbContextOptions<DeviceManagmentDatabaseContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<PackageReference Include="Blazorise.Material" Version="1.1.*" />
|
||||
<PackageReference Include="Blazorise.Icons.Material" Version="1.1.*" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using Blazorise;
|
||||
using Blazorise.Icons.Material;
|
||||
using Blazorise.Material;
|
||||
using Elektrifikatsiya.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddDbContext<DeviceManagmentDatabaseContext>((options)=>options.UseSqlite("Data Source=./DeviceManagement.sqlite"));
|
||||
|
||||
AddBlazorise(builder.Services);
|
||||
|
||||
@@ -32,6 +35,11 @@ app.UseEndpoints(endpoints =>
|
||||
_ = endpoints.MapFallbackToPage("/_Host");
|
||||
});
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
AsyncServiceScope scope = app.Services.CreateAsyncScope();
|
||||
scope.ServiceProvider.GetRequiredService<DeviceManagmentDatabaseContext>().Database.EnsureCreated();
|
||||
|
||||
app.Run();
|
||||
|
||||
void AddBlazorise(IServiceCollection services)
|
||||
|
||||
Reference in New Issue
Block a user