This repository has been archived on 2024-06-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2023-11-22 06:51:08 +01:00

31 lines
975 B
C#

using Lookup.Database.Configurations;
using Lookup.Interface;
using Microsoft.EntityFrameworkCore;
namespace Lookup.Database;
/// <summary>
/// Basic <see cref="DbContext"/>
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
public class LookupDbContext<TKey, TValue> : DbContext
where TKey : class, IKeyEntity<TKey, TValue>
where TValue : class, IRelated<TKey>, IValueEntity<TKey, TValue>
{
/// <summary>
/// Stored <see cref="IKeyEntity{TKey,TValue}"/> instances
/// </summary>
public virtual DbSet<IKeyEntity<TKey, TValue>> Keys { get; set; } = null!;
/// <summary>
/// Stored <see cref="IValueEntity{TKey,TValue}"/> instances
/// </summary>
public virtual DbSet<IValueEntity<TKey, TValue>> Values { get; set; } = null!;
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new LookupConfiguration<TKey, TValue>());
}
}