IW4M-Admin/SharedLibraryCore/Database/ContextSeed.cs
RaidMax 2cceb2f3e7 make database seed code less verbose
disable killserver command
fix issue with default parser not saving during setup
fix issue with unban reason displayed when player is rebanned
2019-04-28 20:54:11 -05:00

52 lines
1.4 KiB
C#

using Microsoft.EntityFrameworkCore;
using SharedLibraryCore.Database.Models;
using System;
using System.Linq;
using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFClient;
namespace SharedLibraryCore.Database
{
public class ContextSeed
{
private DatabaseContext context;
public ContextSeed(DatabaseContext ctx)
{
context = ctx;
}
public async Task Seed()
{
context.Database.Migrate();
if (context.AliasLinks.Count() == 0)
{
var link = new EFAliasLink();
context.Clients.Add(new EFClient()
{
ClientId = 1,
Active = false,
Connections = 0,
FirstConnection = DateTime.UtcNow,
LastConnection = DateTime.UtcNow,
Level = Permission.Console,
Masked = true,
NetworkId = 0,
AliasLink = link,
CurrentAlias = new EFAlias()
{
Link = link,
Active = true,
DateAdded = DateTime.UtcNow,
Name = "IW4MAdmin",
},
});
await context.SaveChangesAsync();
}
}
}
}