修改迁移配置
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||
{
|
||||
public class SubjectConfigration : IEntityTypeConfiguration<Subject>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<Subject> builder)
|
||||
{
|
||||
|
||||
//不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置
|
||||
builder.HasOne(s => s.LatestSubjectVisit);
|
||||
builder.HasOne(s => s.FinalSubjectVisit);
|
||||
builder.HasMany(s => s.SubejectVisitList).WithOne(sv => sv.Subject);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestOneConfigration : IEntityTypeConfiguration<TestOne>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<TestOne> builder)
|
||||
{
|
||||
|
||||
builder.HasOne(s => s.LatestTestMany).WithMany().HasForeignKey(t=>t.LatestTestManyId);
|
||||
builder.HasOne(s => s.FinalTestMany).WithMany().HasForeignKey(t => t.FinalTestManyId);
|
||||
builder.HasMany(s => s.TestManyList).WithOne(sv => sv.TestOne).HasForeignKey(t => t.TestOneId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user