[CHANGE] Preparing database
This commit is contained in:
31
Manager.Data/Contexts/ApplicationDbContext.cs
Normal file
31
Manager.Data/Contexts/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Manager.Data.Models.ApplicationContext;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Manager.Data.Contexts;
|
||||||
|
|
||||||
|
public sealed class ApplicationDbContext : DbContext
|
||||||
|
{
|
||||||
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
||||||
|
ChangeTracker.LazyLoadingEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<SettingsGroupModel> SettingsGroups { get; set; }
|
||||||
|
public DbSet<SettingsModel> Settings { get; set; }
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<SettingsGroupModel>(sg =>
|
||||||
|
{
|
||||||
|
sg.ToTable("settings_groups");
|
||||||
|
sg.HasKey(x => x.Id);
|
||||||
|
});
|
||||||
|
modelBuilder.Entity<SettingsModel>(settingsEntity =>
|
||||||
|
{
|
||||||
|
settingsEntity.ToTable("settings");
|
||||||
|
settingsEntity.HasKey(x => x.Key);
|
||||||
|
});
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
11
Manager.Data/Contexts/LibraryDbContext.cs
Normal file
11
Manager.Data/Contexts/LibraryDbContext.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Manager.Data.Contexts;
|
||||||
|
|
||||||
|
public class LibraryDbContext : DbContext
|
||||||
|
{
|
||||||
|
public LibraryDbContext(DbContextOptions<LibraryDbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
2
Manager.Data/DataService.cs
Normal file
2
Manager.Data/DataService.cs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
namespace Manager.Data;
|
||||||
|
|
@@ -10,4 +10,14 @@
|
|||||||
<ProjectReference Include="..\Manager.Shared\Manager.Shared.csproj" />
|
<ProjectReference Include="..\Manager.Shared\Manager.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
|
<Folder Include="Models\LibraryContext\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Manager.Data.Models.ApplicationContext;
|
||||||
|
|
||||||
|
public record SettingsGroupModel
|
||||||
|
{
|
||||||
|
public required Guid Id { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
}
|
12
Manager.Data/Models/ApplicationContext/SettingsModel.cs
Normal file
12
Manager.Data/Models/ApplicationContext/SettingsModel.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Manager.Data.Models.ApplicationContext;
|
||||||
|
|
||||||
|
public class SettingsModel
|
||||||
|
{
|
||||||
|
public required string Key { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required string Description { get; set; }
|
||||||
|
public Guid? GroupId { get; set; }
|
||||||
|
public string ValueType { get; set; } = nameof(String);
|
||||||
|
public object? Value { get; set; }
|
||||||
|
public object? DefaultValue { get; set; }
|
||||||
|
}
|
Reference in New Issue
Block a user