ql_apimanager_backend/Apimanager_backend/Data/OperationLogConfig.cs

23 lines
664 B
C#

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