Files
WatchIt/WatchIt.Database/Configuration/Accounts/AccountRefreshTokenConfiguration.cs

44 lines
1.2 KiB
C#
Raw Permalink Normal View History

using Microsoft.EntityFrameworkCore;
2024-04-27 22:36:16 +02:00
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WatchIt.Database.Model.Accounts;
2024-04-27 22:36:16 +02:00
namespace WatchIt.Database.Configuration.Accounts;
2024-04-27 22:36:16 +02:00
public class AccountRefreshTokenConfiguration : IEntityTypeConfiguration<AccountRefreshToken>
{
#region PUBLIC METHODS
2024-04-27 22:36:16 +02:00
public void Configure(EntityTypeBuilder<AccountRefreshToken> builder)
{
builder.ToTable("AccountRefreshTokens", "accounts");
// Id
builder.HasKey(x => x.Token);
builder.HasIndex(x => x.Token)
2024-04-27 22:36:16 +02:00
.IsUnique();
builder.Property(x => x.Token)
2024-04-27 22:36:16 +02:00
.IsRequired();
// Account
2024-04-27 22:36:16 +02:00
builder.HasOne(x => x.Account)
.WithMany(x => x.RefreshTokens)
2024-04-27 22:36:16 +02:00
.HasForeignKey(x => x.AccountId)
.IsRequired();
builder.Property(x => x.AccountId)
.IsRequired();
// Expiration date
2024-04-27 22:36:16 +02:00
builder.Property(x => x.ExpirationDate)
.IsRequired();
// Is extendable
2024-04-27 22:36:16 +02:00
builder.Property(x => x.IsExtendable)
.IsRequired();
// Version
builder.Property(b => b.Version)
.IsRowVersion();
2024-04-27 22:36:16 +02:00
}
#endregion
2024-04-27 22:36:16 +02:00
}