[CHANGE] Reworked entities and contexts

This commit is contained in:
max
2025-08-18 00:46:40 +02:00
parent a62eeb727a
commit f784000393
18 changed files with 23 additions and 78 deletions

View File

@@ -1,33 +0,0 @@
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);
}
}

View File

@@ -1,5 +1,5 @@
using Manager.Data.Models.LibraryContext;
using Manager.Data.Models.LibraryContext.Join;
using Manager.Data.Entities.LibraryContext;
using Manager.Data.Entities.LibraryContext.Join;
using Microsoft.EntityFrameworkCore;
namespace Manager.Data.Contexts;

View File

@@ -1,2 +0,0 @@
namespace Manager.Data;

View File

@@ -1,4 +1,4 @@
namespace Manager.Data.Models;
namespace Manager.Data.Entities;
public abstract class DateTimeBase
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class CaptionEntity
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class ChannelEntity : DateTimeBase
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class ClientAccountEntity : DateTimeBase
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class HttpCookieEntity : DateTimeBase
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext.Join;
namespace Manager.Data.Entities.LibraryContext.Join;
public class PlaylistMedia
{

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Manager.Data.Models.LibraryContext.Join;
using Manager.Data.Entities.LibraryContext.Join;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class MediaEntity : DateTimeBase
{

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class MediaFormatEntity
{

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Manager.Data.Models.LibraryContext.Join;
using Manager.Data.Entities.LibraryContext.Join;
namespace Manager.Data.Models.LibraryContext;
namespace Manager.Data.Entities.LibraryContext;
public class PlaylistEntity : DateTimeBase
{

View File

@@ -17,6 +17,8 @@
<ItemGroup>
<Folder Include="Migrations\" />
<Folder Include="Models\" />
<Folder Include="Services\" />
</ItemGroup>
</Project>

View File

@@ -1,7 +0,0 @@
namespace Manager.Data.Models.ApplicationContext;
public record SettingsGroupModel
{
public required Guid Id { get; set; }
public required string Name { get; set; }
}

View File

@@ -1,18 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.ApplicationContext;
public class SettingsModel
{
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public required string Key { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public required string Name { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbDescriptionStringSize)]
public required string Description { get; set; }
public Guid? GroupId { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public string ValueType { get; set; } = nameof(String);
public object? Value { get; set; }
public object? DefaultValue { get; set; }
}