Working on Networking

This commit is contained in:
dingo
2025-11-07 09:03:02 -05:00
parent 6c4ba9b568
commit 28f7c83b64
24 changed files with 2023 additions and 20 deletions
+33
View File
@@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace Server.Data;
public sealed class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<GameDbContext>
{
public GameDbContext CreateDbContext(string[] args)
{
string cs;
try { cs = ConnectionStringFactory.BuildMySqlFromEnv(); }
catch
{
var cfg = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true)
.AddUserSecrets<DesignTimeDbContextFactory>(optional: true)
.AddEnvironmentVariables()
.Build();
cs = cfg.GetConnectionString("PrimaryMySql")
?? cfg["Database:ConnectionString"]
?? "Server=localhost;Port=3306;Database=systemrevival;User Id=root;Password=pass;";
}
var opts = new DbContextOptionsBuilder<GameDbContext>()
.UseMySql(cs, ServerVersion.AutoDetect(cs))
.Options;
return new GameDbContext(opts);
}
}