mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
implemented psn crawling for ps3 game metadata (mostly for thumbnails) implemented game thumbnails for game embeds fixed usage of dbcontext some other bugfixes
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
|
namespace CompatBot.Database
|
|
{
|
|
internal static class PrimaryKeyConvention
|
|
{
|
|
public static void ConfigureDefaultPkConvention(this ModelBuilder modelBuilder, string keyProperty = "Id")
|
|
{
|
|
if (string.IsNullOrEmpty(keyProperty))
|
|
throw new ArgumentException(nameof(keyProperty));
|
|
|
|
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
|
{
|
|
var pk = entity.GetKeys().FirstOrDefault(k => k.IsPrimaryKey());
|
|
if (pk != null)
|
|
pk.Relational().Name = keyProperty;
|
|
}
|
|
}
|
|
|
|
public static void ConfigureNoPkConvention(this ModelBuilder modelBuilder)
|
|
{
|
|
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
|
{
|
|
var pk = entity.GetKeys().FirstOrDefault(k => k.IsPrimaryKey());
|
|
if (pk != null)
|
|
entity.RemoveKey(pk.Properties);
|
|
}
|
|
}
|
|
}
|
|
} |