27 lines
802 B
C#
27 lines
802 B
C#
using Apimanager_backend.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Apimanager_backend.Data
|
|
{
|
|
public class UserConfig : IEntityTypeConfiguration<User>
|
|
{
|
|
public void Configure(EntityTypeBuilder<User> builder)
|
|
{
|
|
//主键
|
|
builder.HasKey(x => x.Id);
|
|
//自增
|
|
builder.Property(x => x.Id)
|
|
.ValueGeneratedOnAdd();
|
|
//唯一索引
|
|
builder.HasIndex(x => x.Username)
|
|
.IsUnique();
|
|
builder.HasIndex(x => x.Email)
|
|
.IsUnique();
|
|
builder.HasData(
|
|
new User(-1,"admin", "admin1@admin.com","e10adc3949ba59abbe56e057f20f883e")
|
|
);
|
|
}
|
|
}
|
|
}
|