修改迁移配置
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||
{
|
||||
public class DictionaryConfigration : IEntityTypeConfiguration<Dictionary>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<Dictionary> builder)
|
||||
{
|
||||
|
||||
|
||||
builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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