27 lines
737 B
C#
27 lines
737 B
C#
using Apimanager_backend.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Apimanager_backend.Data
|
|
{
|
|
public class ApiConfig : IEntityTypeConfiguration<Api>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Api> builder)
|
|
{
|
|
//主键
|
|
builder.HasKey(x => x.Id);
|
|
//自增
|
|
builder.Property(x => x.Id)
|
|
.ValueGeneratedOnAdd();
|
|
//设置唯一
|
|
builder.HasIndex(x => x.Endpoint)
|
|
.IsUnique();
|
|
//外键
|
|
builder.HasOne(x => x.Package)
|
|
.WithMany(u => u.Apis)
|
|
.HasForeignKey(x => x.PackageId);
|
|
|
|
}
|
|
}
|
|
}
|