diff --git a/Manager.Data/Contexts/ApplicationDbContext.cs b/Manager.Data/Contexts/ApplicationDbContext.cs new file mode 100644 index 0000000..efe4a07 --- /dev/null +++ b/Manager.Data/Contexts/ApplicationDbContext.cs @@ -0,0 +1,31 @@ +using Manager.Data.Models.ApplicationContext; +using Microsoft.EntityFrameworkCore; + +namespace Manager.Data.Contexts; + +public sealed class ApplicationDbContext : DbContext +{ + public ApplicationDbContext(DbContextOptions options) : base(options) + { + ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; + ChangeTracker.LazyLoadingEnabled = false; + } + + public DbSet SettingsGroups { get; set; } + public DbSet Settings { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(sg => + { + sg.ToTable("settings_groups"); + sg.HasKey(x => x.Id); + }); + modelBuilder.Entity(settingsEntity => + { + settingsEntity.ToTable("settings"); + settingsEntity.HasKey(x => x.Key); + }); + base.OnModelCreating(modelBuilder); + } +} \ No newline at end of file diff --git a/Manager.Data/Contexts/LibraryDbContext.cs b/Manager.Data/Contexts/LibraryDbContext.cs new file mode 100644 index 0000000..66c363d --- /dev/null +++ b/Manager.Data/Contexts/LibraryDbContext.cs @@ -0,0 +1,11 @@ +using Microsoft.EntityFrameworkCore; + +namespace Manager.Data.Contexts; + +public class LibraryDbContext : DbContext +{ + public LibraryDbContext(DbContextOptions options) : base(options) + { + + } +} \ No newline at end of file diff --git a/Manager.Data/DataService.cs b/Manager.Data/DataService.cs new file mode 100644 index 0000000..9712215 --- /dev/null +++ b/Manager.Data/DataService.cs @@ -0,0 +1,2 @@ +namespace Manager.Data; + diff --git a/Manager.Data/Manager.Data.csproj b/Manager.Data/Manager.Data.csproj index b147586..1d58c45 100644 --- a/Manager.Data/Manager.Data.csproj +++ b/Manager.Data/Manager.Data.csproj @@ -10,4 +10,14 @@ + + + + + + + + + + diff --git a/Manager.Data/Models/ApplicationContext/SettingsGroupModel.cs b/Manager.Data/Models/ApplicationContext/SettingsGroupModel.cs new file mode 100644 index 0000000..abaf1e2 --- /dev/null +++ b/Manager.Data/Models/ApplicationContext/SettingsGroupModel.cs @@ -0,0 +1,7 @@ +namespace Manager.Data.Models.ApplicationContext; + +public record SettingsGroupModel +{ + public required Guid Id { get; set; } + public required string Name { get; set; } +} \ No newline at end of file diff --git a/Manager.Data/Models/ApplicationContext/SettingsModel.cs b/Manager.Data/Models/ApplicationContext/SettingsModel.cs new file mode 100644 index 0000000..601cf10 --- /dev/null +++ b/Manager.Data/Models/ApplicationContext/SettingsModel.cs @@ -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; } +} \ No newline at end of file