mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 21:31:45 +02:00
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
Phantom.Server.Database
Converters
Entities
Factories
ApplicationDbContext.cs
DatabaseProvider.cs
Phantom.Server.Database.csproj
Phantom.Server.Database.Postgres
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Utils
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
PhantomPanel.sln
global.json
32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
using Phantom.Common.Data;
|
|
using Phantom.Common.Data.Minecraft;
|
|
using Phantom.Server.Database.Converters;
|
|
using Phantom.Server.Database.Entities;
|
|
using Phantom.Server.Database.Factories;
|
|
|
|
namespace Phantom.Server.Database;
|
|
|
|
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global")]
|
|
public class ApplicationDbContext : DbContext {
|
|
public DbSet<AgentEntity> Agents { get; set; } = null!;
|
|
public DbSet<InstanceEntity> Instances { get; set; } = null!;
|
|
|
|
public AgentEntityUpsert AgentUpsert { get; }
|
|
public InstanceEntityUpsert InstanceUpsert { get; }
|
|
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) {
|
|
AgentUpsert = new AgentEntityUpsert(this);
|
|
InstanceUpsert = new InstanceEntityUpsert(this);
|
|
}
|
|
|
|
protected override void ConfigureConventions(ModelConfigurationBuilder builder) {
|
|
base.ConfigureConventions(builder);
|
|
|
|
builder.Properties<MinecraftServerKind>().HaveConversion<EnumToStringConverter<MinecraftServerKind>>();
|
|
builder.Properties<RamAllocationUnits>().HaveConversion<RamAllocationUnitsConverter>();
|
|
}
|
|
}
|