Merge pull request #5 from mkbka/master

Add SQLite support
This commit is contained in:
raphael 2024-06-02 12:04:53 +08:00 committed by GitHub
commit 2024bae0a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 1623 additions and 58 deletions

View File

@ -29,7 +29,11 @@ namespace SCHALE.Common.Database
.UseSqlServer(connectionString)
.Options);
public SCHALEContext(DbContextOptions<SCHALEContext> options) : base(options)
public SCHALEContext()
{
}
public SCHALEContext(DbContextOptions options) : base(options)
{
}
@ -100,6 +104,24 @@ namespace SCHALE.Common.Database
}
}
public class SCHALESqliteContext : SCHALEContext
{
public SCHALESqliteContext() { }
public SCHALESqliteContext(DbContextOptions options) : base(options)
{
}
public static SCHALESqliteContext Create(string connectionString) =>
new(new DbContextOptionsBuilder<SCHALESqliteContext>()
.UseSqlite(connectionString).Options);
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=schale.sqlite3");
}
}
public static class PropertyBuilderExtensions
{
public static PropertyBuilder<T> HasJsonConversion<T>(this PropertyBuilder<T> propertyBuilder) where T : class, new()

View File

@ -1,20 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace SCHALE.Common.Database
{
public static class ServicesExtesions
{
public static void AddSQLServerProvider(this IServiceCollection services, string connectionString)
{
services.AddDbContext<SCHALEContext>(o =>
{
o.UseSqlServer(connectionString, b =>
{
b.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
})
.UseLazyLoadingProxies();
}, ServiceLifetime.Singleton, ServiceLifetime.Singleton);
}
}
}

View File

@ -351,9 +351,19 @@ namespace SCHALE.Common.Database
[JsonIgnore]
public virtual RaidInfo RaidInfo { get; set; }
public AccountDB() { }
public AccountDB() {
Items = new List<ItemDB>();
Characters = new List<CharacterDB>();
MissionProgresses = new List<MissionProgressDB>();
Echelons = new List<EchelonDB>();
Equipment = new List<EquipmentDB>();
Weapons = new List<WeaponDB>();
Gears = new List<GearDB>();
MemoryLobbies = new List<MemoryLobbyDB>();
Scenarios = new List<ScenarioHistoryDB>();
}
public AccountDB(long publisherAccountId)
public AccountDB(long publisherAccountId) : this()
{
PublisherAccountId = publisherAccountId;
State = AccountState.Normal;

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240501053823_Init")]

View File

@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Init : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240501071717_CharacterAndRelations")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class CharacterAndRelations : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240501081158_UnMapIsNew")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class UnMapIsNew : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240501090227_Echelons")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Echelons : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240510003553_Equipment")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Equipment : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240510093842_Weapons")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Weapons : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240511074956_Account_RaidSeasonId")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Account_RaidSeasonId : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240518014039_Gears")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class Gears : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240519215605_AccountDB_RaidInfo")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class AccountDB_RaidInfo : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240522122813_EchelonDB_CombatStyleIndex")]

View File

@ -2,7 +2,7 @@
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class EchelonDB_CombatStyleIndex : Migration

View File

@ -9,7 +9,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
[Migration("20240530042248_MemoryLobby_and_Scenario")]

View File

@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
/// <inheritdoc />
public partial class MemoryLobby_and_Scenario : Migration

View File

@ -8,7 +8,7 @@ using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations
namespace SCHALE.Common.Migrations.SqlServerMigrations
{
[DbContext(typeof(SCHALEContext))]
partial class SCHALEContextModelSnapshot : ModelSnapshot

View File

@ -0,0 +1,567 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations.SqliteMigrations
{
[DbContext(typeof(SCHALESqliteContext))]
[Migration("20240601161847_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("BirthDay")
.HasColumnType("TEXT");
b.Property<string>("CallName")
.HasColumnType("TEXT");
b.Property<DateTime>("CallNameUpdateTime")
.HasColumnType("TEXT");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<DateTime>("CreateDate")
.HasColumnType("TEXT");
b.Property<string>("DevId")
.HasColumnType("TEXT");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastConnectTime")
.HasColumnType("TEXT");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LinkRewardDate")
.HasColumnType("TEXT");
b.Property<int>("LobbyMode")
.HasColumnType("INTEGER");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Nickname")
.HasColumnType("TEXT");
b.Property<long>("PublisherAccountId")
.HasColumnType("INTEGER");
b.Property<string>("RaidInfo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("RepresentCharacterServerId")
.HasColumnType("INTEGER");
b.Property<int?>("RetentionDays")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.Property<int?>("UnReadMailCount")
.HasColumnType("INTEGER");
b.Property<int?>("VIPLevel")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.ToTable("Accounts");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("EquipmentServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("EquipmentSlotAndDBIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ExSkillLevel")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<int>("ExtraPassiveSkillLevel")
.HasColumnType("INTEGER");
b.Property<long>("FavorExp")
.HasColumnType("INTEGER");
b.Property<int>("FavorRank")
.HasColumnType("INTEGER");
b.Property<bool>("IsFavorite")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("LeaderSkillLevel")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<int>("PassiveSkillLevel")
.HasColumnType("INTEGER");
b.Property<string>("PotentialStats")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("PublicSkillLevel")
.HasColumnType("INTEGER");
b.Property<int>("StarGrade")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Characters");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("CombatStyleIndex")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("EchelonNumber")
.HasColumnType("INTEGER");
b.Property<int>("EchelonType")
.HasColumnType("INTEGER");
b.Property<int>("ExtensionType")
.HasColumnType("INTEGER");
b.Property<long>("LeaderServerId")
.HasColumnType("INTEGER");
b.Property<string>("MainSlotServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillCardMulliganCharacterIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SupportSlotServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("TSSInteractionServerId")
.HasColumnType("INTEGER");
b.Property<int>("UsingFlag")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Echelons");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<long>("StackCount")
.HasColumnType("INTEGER");
b.Property<int>("Tier")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Equipment");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<long>("SlotIndex")
.HasColumnType("INTEGER");
b.Property<int>("Tier")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Gears");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<long>("StackCount")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Items");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MemoryLobbies");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<bool>("Complete")
.HasColumnType("INTEGER");
b.Property<long>("MissionUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("ProgressParameters")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("StartTime")
.HasColumnType("TEXT");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MissionProgresses");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.AccountTutorial", b =>
{
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("TutorialIds")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AccountServerId");
b.ToTable("AccountTutorials");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.GuestAccount", b =>
{
b.Property<long>("Uid")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("DeviceId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Uid");
b.ToTable("GuestAccounts");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("ClearDateTime")
.HasColumnType("TEXT");
b.Property<long>("ScenarioUniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Scenarios");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<int>("StarGrade")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Weapons");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Characters")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Echelons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Equipment")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Gears")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Items")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MemoryLobbies")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MissionProgresses")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Scenarios")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Weapons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Navigation("Characters");
b.Navigation("Echelons");
b.Navigation("Equipment");
b.Navigation("Gears");
b.Navigation("Items");
b.Navigation("MemoryLobbies");
b.Navigation("MissionProgresses");
b.Navigation("Scenarios");
b.Navigation("Weapons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,384 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SCHALE.Common.Migrations.SqliteMigrations
{
/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
RaidInfo = table.Column<string>(type: "TEXT", nullable: false),
Nickname = table.Column<string>(type: "TEXT", nullable: true),
CallName = table.Column<string>(type: "TEXT", nullable: true),
DevId = table.Column<string>(type: "TEXT", nullable: true),
State = table.Column<int>(type: "INTEGER", nullable: false),
Level = table.Column<int>(type: "INTEGER", nullable: false),
Exp = table.Column<long>(type: "INTEGER", nullable: false),
Comment = table.Column<string>(type: "TEXT", nullable: true),
LobbyMode = table.Column<int>(type: "INTEGER", nullable: false),
RepresentCharacterServerId = table.Column<int>(type: "INTEGER", nullable: false),
MemoryLobbyUniqueId = table.Column<long>(type: "INTEGER", nullable: false),
LastConnectTime = table.Column<DateTime>(type: "TEXT", nullable: false),
BirthDay = table.Column<DateTime>(type: "TEXT", nullable: true),
CallNameUpdateTime = table.Column<DateTime>(type: "TEXT", nullable: false),
PublisherAccountId = table.Column<long>(type: "INTEGER", nullable: false),
RetentionDays = table.Column<int>(type: "INTEGER", nullable: true),
VIPLevel = table.Column<int>(type: "INTEGER", nullable: true),
CreateDate = table.Column<DateTime>(type: "TEXT", nullable: false),
UnReadMailCount = table.Column<int>(type: "INTEGER", nullable: true),
LinkRewardDate = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.ServerId);
});
migrationBuilder.CreateTable(
name: "AccountTutorials",
columns: table => new
{
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
TutorialIds = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AccountTutorials", x => x.AccountServerId);
});
migrationBuilder.CreateTable(
name: "GuestAccounts",
columns: table => new
{
Uid = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DeviceId = table.Column<string>(type: "TEXT", nullable: false),
Token = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GuestAccounts", x => x.Uid);
});
migrationBuilder.CreateTable(
name: "Characters",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
UniqueId = table.Column<long>(type: "INTEGER", nullable: false),
StarGrade = table.Column<int>(type: "INTEGER", nullable: false),
Level = table.Column<int>(type: "INTEGER", nullable: false),
Exp = table.Column<long>(type: "INTEGER", nullable: false),
FavorRank = table.Column<int>(type: "INTEGER", nullable: false),
FavorExp = table.Column<long>(type: "INTEGER", nullable: false),
PublicSkillLevel = table.Column<int>(type: "INTEGER", nullable: false),
ExSkillLevel = table.Column<int>(type: "INTEGER", nullable: false),
PassiveSkillLevel = table.Column<int>(type: "INTEGER", nullable: false),
ExtraPassiveSkillLevel = table.Column<int>(type: "INTEGER", nullable: false),
LeaderSkillLevel = table.Column<int>(type: "INTEGER", nullable: false),
IsLocked = table.Column<bool>(type: "INTEGER", nullable: false),
IsFavorite = table.Column<bool>(type: "INTEGER", nullable: false),
EquipmentServerIds = table.Column<string>(type: "TEXT", nullable: false),
PotentialStats = table.Column<string>(type: "TEXT", nullable: false),
EquipmentSlotAndDBIds = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Characters", x => x.ServerId);
table.ForeignKey(
name: "FK_Characters_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Echelons",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
EchelonType = table.Column<int>(type: "INTEGER", nullable: false),
EchelonNumber = table.Column<long>(type: "INTEGER", nullable: false),
ExtensionType = table.Column<int>(type: "INTEGER", nullable: false),
LeaderServerId = table.Column<long>(type: "INTEGER", nullable: false),
MainSlotServerIds = table.Column<string>(type: "TEXT", nullable: false),
SupportSlotServerIds = table.Column<string>(type: "TEXT", nullable: false),
TSSInteractionServerId = table.Column<long>(type: "INTEGER", nullable: false),
UsingFlag = table.Column<int>(type: "INTEGER", nullable: false),
SkillCardMulliganCharacterIds = table.Column<string>(type: "TEXT", nullable: false),
CombatStyleIndex = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Echelons", x => x.ServerId);
table.ForeignKey(
name: "FK_Echelons_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Equipment",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Level = table.Column<int>(type: "INTEGER", nullable: false),
Exp = table.Column<long>(type: "INTEGER", nullable: false),
Tier = table.Column<int>(type: "INTEGER", nullable: false),
BoundCharacterServerId = table.Column<long>(type: "INTEGER", nullable: false),
IsLocked = table.Column<bool>(type: "INTEGER", nullable: false),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
UniqueId = table.Column<long>(type: "INTEGER", nullable: false),
StackCount = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Equipment", x => x.ServerId);
table.ForeignKey(
name: "FK_Equipment_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Gears",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
UniqueId = table.Column<long>(type: "INTEGER", nullable: false),
Level = table.Column<int>(type: "INTEGER", nullable: false),
Exp = table.Column<long>(type: "INTEGER", nullable: false),
Tier = table.Column<int>(type: "INTEGER", nullable: false),
SlotIndex = table.Column<long>(type: "INTEGER", nullable: false),
BoundCharacterServerId = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Gears", x => x.ServerId);
table.ForeignKey(
name: "FK_Gears_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Items",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
IsLocked = table.Column<bool>(type: "INTEGER", nullable: false),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
UniqueId = table.Column<long>(type: "INTEGER", nullable: false),
StackCount = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.ServerId);
table.ForeignKey(
name: "FK_Items_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MemoryLobbies",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
MemoryLobbyUniqueId = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MemoryLobbies", x => x.ServerId);
table.ForeignKey(
name: "FK_MemoryLobbies_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MissionProgresses",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
MissionUniqueId = table.Column<long>(type: "INTEGER", nullable: false),
Complete = table.Column<bool>(type: "INTEGER", nullable: false),
StartTime = table.Column<DateTime>(type: "TEXT", nullable: false),
ProgressParameters = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MissionProgresses", x => x.ServerId);
table.ForeignKey(
name: "FK_MissionProgresses_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Scenarios",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
ScenarioUniqueId = table.Column<long>(type: "INTEGER", nullable: false),
ClearDateTime = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Scenarios", x => x.ServerId);
table.ForeignKey(
name: "FK_Scenarios_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Weapons",
columns: table => new
{
ServerId = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountServerId = table.Column<long>(type: "INTEGER", nullable: false),
UniqueId = table.Column<long>(type: "INTEGER", nullable: false),
Level = table.Column<int>(type: "INTEGER", nullable: false),
Exp = table.Column<long>(type: "INTEGER", nullable: false),
StarGrade = table.Column<int>(type: "INTEGER", nullable: false),
BoundCharacterServerId = table.Column<long>(type: "INTEGER", nullable: false),
IsLocked = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Weapons", x => x.ServerId);
table.ForeignKey(
name: "FK_Weapons_Accounts_AccountServerId",
column: x => x.AccountServerId,
principalTable: "Accounts",
principalColumn: "ServerId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Characters_AccountServerId",
table: "Characters",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Echelons_AccountServerId",
table: "Echelons",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Equipment_AccountServerId",
table: "Equipment",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Gears_AccountServerId",
table: "Gears",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Items_AccountServerId",
table: "Items",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_MemoryLobbies_AccountServerId",
table: "MemoryLobbies",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_MissionProgresses_AccountServerId",
table: "MissionProgresses",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Scenarios_AccountServerId",
table: "Scenarios",
column: "AccountServerId");
migrationBuilder.CreateIndex(
name: "IX_Weapons_AccountServerId",
table: "Weapons",
column: "AccountServerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AccountTutorials");
migrationBuilder.DropTable(
name: "Characters");
migrationBuilder.DropTable(
name: "Echelons");
migrationBuilder.DropTable(
name: "Equipment");
migrationBuilder.DropTable(
name: "Gears");
migrationBuilder.DropTable(
name: "GuestAccounts");
migrationBuilder.DropTable(
name: "Items");
migrationBuilder.DropTable(
name: "MemoryLobbies");
migrationBuilder.DropTable(
name: "MissionProgresses");
migrationBuilder.DropTable(
name: "Scenarios");
migrationBuilder.DropTable(
name: "Weapons");
migrationBuilder.DropTable(
name: "Accounts");
}
}
}

View File

@ -0,0 +1,564 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SCHALE.Common.Database;
#nullable disable
namespace SCHALE.Common.Migrations.SqliteMigrations
{
[DbContext(typeof(SCHALESqliteContext))]
partial class SCHALESqliteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("BirthDay")
.HasColumnType("TEXT");
b.Property<string>("CallName")
.HasColumnType("TEXT");
b.Property<DateTime>("CallNameUpdateTime")
.HasColumnType("TEXT");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<DateTime>("CreateDate")
.HasColumnType("TEXT");
b.Property<string>("DevId")
.HasColumnType("TEXT");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastConnectTime")
.HasColumnType("TEXT");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LinkRewardDate")
.HasColumnType("TEXT");
b.Property<int>("LobbyMode")
.HasColumnType("INTEGER");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("Nickname")
.HasColumnType("TEXT");
b.Property<long>("PublisherAccountId")
.HasColumnType("INTEGER");
b.Property<string>("RaidInfo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("RepresentCharacterServerId")
.HasColumnType("INTEGER");
b.Property<int?>("RetentionDays")
.HasColumnType("INTEGER");
b.Property<int>("State")
.HasColumnType("INTEGER");
b.Property<int?>("UnReadMailCount")
.HasColumnType("INTEGER");
b.Property<int?>("VIPLevel")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.ToTable("Accounts");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("EquipmentServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("EquipmentSlotAndDBIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("ExSkillLevel")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<int>("ExtraPassiveSkillLevel")
.HasColumnType("INTEGER");
b.Property<long>("FavorExp")
.HasColumnType("INTEGER");
b.Property<int>("FavorRank")
.HasColumnType("INTEGER");
b.Property<bool>("IsFavorite")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("LeaderSkillLevel")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<int>("PassiveSkillLevel")
.HasColumnType("INTEGER");
b.Property<string>("PotentialStats")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("PublicSkillLevel")
.HasColumnType("INTEGER");
b.Property<int>("StarGrade")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Characters");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("CombatStyleIndex")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("EchelonNumber")
.HasColumnType("INTEGER");
b.Property<int>("EchelonType")
.HasColumnType("INTEGER");
b.Property<int>("ExtensionType")
.HasColumnType("INTEGER");
b.Property<long>("LeaderServerId")
.HasColumnType("INTEGER");
b.Property<string>("MainSlotServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SkillCardMulliganCharacterIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SupportSlotServerIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long>("TSSInteractionServerId")
.HasColumnType("INTEGER");
b.Property<int>("UsingFlag")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Echelons");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<long>("StackCount")
.HasColumnType("INTEGER");
b.Property<int>("Tier")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Equipment");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<long>("SlotIndex")
.HasColumnType("INTEGER");
b.Property<int>("Tier")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Gears");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<long>("StackCount")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Items");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("MemoryLobbyUniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MemoryLobbies");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<bool>("Complete")
.HasColumnType("INTEGER");
b.Property<long>("MissionUniqueId")
.HasColumnType("INTEGER");
b.Property<string>("ProgressParameters")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("StartTime")
.HasColumnType("TEXT");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("MissionProgresses");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.AccountTutorial", b =>
{
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<string>("TutorialIds")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AccountServerId");
b.ToTable("AccountTutorials");
});
modelBuilder.Entity("SCHALE.Common.Database.Models.GuestAccount", b =>
{
b.Property<long>("Uid")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("DeviceId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Uid");
b.ToTable("GuestAccounts");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("ClearDateTime")
.HasColumnType("TEXT");
b.Property<long>("ScenarioUniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Scenarios");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.Property<long>("ServerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountServerId")
.HasColumnType("INTEGER");
b.Property<long>("BoundCharacterServerId")
.HasColumnType("INTEGER");
b.Property<long>("Exp")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<int>("Level")
.HasColumnType("INTEGER");
b.Property<int>("StarGrade")
.HasColumnType("INTEGER");
b.Property<long>("UniqueId")
.HasColumnType("INTEGER");
b.HasKey("ServerId");
b.HasIndex("AccountServerId");
b.ToTable("Weapons");
});
modelBuilder.Entity("SCHALE.Common.Database.CharacterDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Characters")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EchelonDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Echelons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.EquipmentDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Equipment")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.GearDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Gears")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ItemDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Items")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MemoryLobbyDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MemoryLobbies")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.MissionProgressDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("MissionProgresses")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.ScenarioHistoryDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Scenarios")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.WeaponDB", b =>
{
b.HasOne("SCHALE.Common.Database.AccountDB", "Account")
.WithMany("Weapons")
.HasForeignKey("AccountServerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Account");
});
modelBuilder.Entity("SCHALE.Common.Database.AccountDB", b =>
{
b.Navigation("Characters");
b.Navigation("Echelons");
b.Navigation("Equipment");
b.Navigation("Gears");
b.Navigation("Items");
b.Navigation("MemoryLobbies");
b.Navigation("MissionProgresses");
b.Navigation("Scenarios");
b.Navigation("Weapons");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -14,6 +14,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCHALE.GameServer", "SCHALE.GameServer\SCHALE.GameServer.csproj", "{FA808FE1-3F81-4AFC-9FBE-8662B9781EF8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SCHALE.GameServer", "SCHALE.GameServer\SCHALE.GameServer.csproj", "{FA808FE1-3F81-4AFC-9FBE-8662B9781EF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCHALE.Common", "SCHALE.Common\SCHALE.Common.csproj", "{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SCHALE.Common", "SCHALE.Common\SCHALE.Common.csproj", "{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

1
SCHALE.GameServer/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
schale.sqlite3*

View File

@ -81,12 +81,7 @@ namespace SCHALE.GameServer
builder.Host.UseSerilog();
// Add services to the container.
builder.Services.AddSQLServerProvider(
config.GetConnectionString("SQLServer")
?? throw new ArgumentNullException(
"ConnectionStrings/SQLServer in appsettings is missing"
)
);
builder.Services.AddDbProvider(config);
builder.Services.AddControllers();
builder.Services.AddProtocolHandlerFactory();
builder.Services.AddMemorySessionKeyService();

View File

@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using SCHALE.Common.Database;
namespace SCHALE.GameServer.Utils
{
public static class ServicesExtesions
{
public static Exception NoConnectionStringException = new ArgumentNullException($"ConnectionString in appsettings is missing");
public static void AddDbProvider(this IServiceCollection services, IConfiguration conf)
{
var sqlProvider = conf.GetValue<string>("SQL Provider");
switch (sqlProvider)
{
case "SQLite3":
services.AddDbContext<SCHALEContext, SCHALESqliteContext>(opt =>
opt
.UseSqlite(conf.GetConnectionString("SQLite3") ?? throw NoConnectionStringException)
.UseLazyLoadingProxies()
, ServiceLifetime.Singleton, ServiceLifetime.Singleton);
break;
case "SQLServer":
services.AddDbContext<SCHALEContext>(opt =>
opt
.UseSqlServer(conf.GetConnectionString("SQLServer") ?? throw NoConnectionStringException,
actions =>
{
actions.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
})
.UseLazyLoadingProxies()
, ServiceLifetime.Singleton, ServiceLifetime.Singleton);
break;
default: throw new ArgumentException($"SQL Provider '{sqlProvider}' is not valid");
}
}
}
}

View File

@ -1,5 +1,7 @@
{
"SQL Provider": "SQLServer",
"ConnectionStrings": {
"SQLite3": "Data Source=schale.sqlite3",
"SQLServer": "data source=db;User=sa;Password=5CH41364M353rV3r;initial catalog=schale;trusted_connection=false;TrustServerCertificate=True"
}
}

View File

@ -15,7 +15,9 @@
}
}
},
"SQL Provider": "SQLServer",
"ConnectionStrings": {
"SQLite3": "Data Source=schale.sqlite3",
"SQLServer": "data source=localhost\\SQLEXPRESS;initial catalog=schale;trusted_connection=true;TrustServerCertificate=True"
},
"AllowedHosts": "*"