[CHANGE] Reworked entities and contexts
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -1,2 +0,0 @@
|
||||
namespace Manager.Data;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Manager.Data.Models;
|
||||
namespace Manager.Data.Entities;
|
||||
|
||||
public abstract class DateTimeBase
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext;
|
||||
namespace Manager.Data.Entities.LibraryContext;
|
||||
|
||||
public class CaptionEntity
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext;
|
||||
namespace Manager.Data.Entities.LibraryContext;
|
||||
|
||||
public class ChannelEntity : DateTimeBase
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext;
|
||||
namespace Manager.Data.Entities.LibraryContext;
|
||||
|
||||
public class ClientAccountEntity : DateTimeBase
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext;
|
||||
namespace Manager.Data.Entities.LibraryContext;
|
||||
|
||||
public class HttpCookieEntity : DateTimeBase
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext.Join;
|
||||
namespace Manager.Data.Entities.LibraryContext.Join;
|
||||
|
||||
public class PlaylistMedia
|
||||
{
|
@@ -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
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.Data.Models.LibraryContext;
|
||||
namespace Manager.Data.Entities.LibraryContext;
|
||||
|
||||
public class MediaFormatEntity
|
||||
{
|
@@ -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
|
||||
{
|
@@ -17,6 +17,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -1,7 +0,0 @@
|
||||
namespace Manager.Data.Models.ApplicationContext;
|
||||
|
||||
public record SettingsGroupModel
|
||||
{
|
||||
public required Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
}
|
@@ -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; }
|
||||
}
|
Reference in New Issue
Block a user