ql_apimanager_backend/Apimanager_backend/Data/ApiCallLogConfig.cs

27 lines
815 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Apimanager_backend.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Apimanager_backend.Data
{
public class ApiCallLogConfig : IEntityTypeConfiguration<ApiCallLog>
{
public void Configure(EntityTypeBuilder<ApiCallLog> builder)
{
//主键
builder.HasKey(x => x.Id);
//自增
builder.Property(x => x.Id)
.ValueGeneratedOnAdd();
//外键API
builder.HasOne(x => x.Api)
.WithMany(u => u.ApiCalls)
.HasForeignKey(x => x.ApiId);
//外键User
builder.HasOne(x => x.User)
.WithMany(u => u.CallLogs)
.HasForeignKey(x => x.UserId);
}
}
}