Files
void.cat/VoidCat/Database/Configurations/ApiKeyConfiguration.cs
Kieran 4de977c1dd v5 (#65)
Co-authored-by: Kieran <kieran@harkin.me>
Reviewed-on: https://git.v0l.io/Kieran/void.cat/pulls/65
2023-05-09 13:56:57 +00:00

26 lines
659 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace VoidCat.Database.Configurations;
public class ApiKeyConfiguration : IEntityTypeConfiguration<ApiKey>
{
public void Configure(EntityTypeBuilder<ApiKey> builder)
{
builder.ToTable("ApiKey");
builder.HasKey(a => a.Id);
builder.Property(a => a.Token)
.IsRequired();
builder.Property(a => a.Expiry)
.IsRequired();
builder.Property(a => a.Created)
.IsRequired();
builder.HasOne(a => a.User)
.WithMany()
.HasForeignKey(a => a.UserId);
}
}