Added AppUser navigation property to AuditLog entity with EF Core configuration (FK -> UserId, SetNull on delete). Replaced the sub-query in AuditLogService ListAsync with a direct navigation property access, enabling EF Core to generate a single LEFT JOIN instead of N sub-queries. Migration: AddAuditLogUserRelation
31 lines
889 B
C#
31 lines
889 B
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Heimdall.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddAuditLogUserRelation : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_audit_logs_users_UserId",
|
|
table: "audit_logs",
|
|
column: "UserId",
|
|
principalTable: "users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_audit_logs_users_UserId",
|
|
table: "audit_logs");
|
|
}
|
|
}
|
|
}
|