Skip to content

Commit

Permalink
Create abstract database schema
Browse files Browse the repository at this point in the history
  • Loading branch information
zobweyt committed Jun 11, 2024
1 parent 899e939 commit ec8309c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/Giveaways.Data/Models/DbEntity.cs

This file was deleted.

28 changes: 28 additions & 0 deletions src/Giveaways.Data/Models/KeyedEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Discord;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Giveaways.Data;

/// <summary>
/// Represents an abstract class for entities with a key identifier.
/// </summary>
/// <typeparam name="TId">The type of the key identifier.</typeparam>
public abstract class KeyedEntity<TId> : IEntity<TId>
where TId : IEquatable<TId>
{
public TId Id { get; init; } = default!;
}

/// <summary>
/// Represents an abstract class for configuring entities with a key identifier.
/// </summary>
/// <typeparam name="TId">The type of the key identifier.</typeparam>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
internal abstract class KeyedEntityConfiguration<TId, TEntity> : IEntityTypeConfiguration<TEntity>
where TId : IEquatable<TId>
where TEntity : KeyedEntity<TId>
{
public abstract void Configure(EntityTypeBuilder<TEntity> builder);
}

0 comments on commit ec8309c

Please sign in to comment.