This commit is contained in:
2026-10-04 18:11:46 +03:30
parent 0f0e078c8e
commit b7fba89157
2 changed files with 57 additions and 3 deletions
+24 -3
View File
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using xIdentityModels;
using xIdentityModels.Models;
using xIdentityModels.Navigations;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace xIds.DbContext
{
@@ -13,7 +13,10 @@ namespace xIds.DbContext
#region Props/DbSets ...
public DbSet<XToken> Tokens { get; set; }
public DbSet<XDevice> Devices { get; set; }
public DbSet<XApiKey> ApiKeys { get; set; }
public DbSet<XProfileImage> Avatars { get; set; }
public DbSet<XApiKeyUsage> ApiKeyUsage { get; set; }
public DbSet<XApplication> Applications { get; set; }
public DbSet<XBannedDevice> BannedDevices { get; set; }
public DbSet<XFriendshipFollower> Followers { get; set; }
public DbSet<XFriendshipFollowing> Followings { get; set; }
@@ -52,6 +55,24 @@ namespace xIds.DbContext
.HasForeignKey(ur => ur.UserId)
.IsRequired();
});
//
// Configure XApplication ...
modelBuilder.Entity<XApplication>(e =>
{
e.HasIndex(a => a.Name).IsUnique();
e.HasMany(a => a.ApiKeys)
.WithOne(k => k.Application)
.HasForeignKey(k => k.ApplicationId);
});
//
// Configure XApiKey ...
modelBuilder.Entity<XApiKey>(e =>
{
e.HasIndex(k => k.KeyHash).IsUnique();
e.HasIndex(k => k.ExpiresAt);
});
}
}
}