diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index cc66071dc..70e4e83cb 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -238,33 +238,7 @@ namespace IRaCIS.Core.API.Controllers - [HttpPost, Route("Study/PreArchiveStudy")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task PreArchiveStudy(PreArchiveStudyCommand preArchiveStudyCommand, - [FromServices] IStudyService _studyService, - [FromServices] IRepository _studyMonitorRepository) - { - var savedInfo = _studyService.GetSaveToDicomInfo(preArchiveStudyCommand.SubjectVisitId); - - var studyMonitor = new StudyMonitor() - { - TrialId = savedInfo.TrialId, - SubjectId = savedInfo.SubjectId, - SubjectVisitId = savedInfo.SubjectVisitId, - - IsSuccess = false, - UploadStartTime = DateTime.Now, - IsDicom = preArchiveStudyCommand.IsDicom, - IP = _userInfo.IP - }; - - - var addEntity = await _studyMonitorRepository.AddAsync(studyMonitor, true); - - return ResponseOutput.Ok(addEntity.Id); - - } /// Dicom 归档 @@ -446,7 +420,33 @@ namespace IRaCIS.Core.API.Controllers public string FileType { get; set; } } } + [HttpPost, Route("Study/PreArchiveStudy")] + [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] + public async Task PreArchiveStudy(PreArchiveStudyCommand preArchiveStudyCommand, + [FromServices] IStudyService _studyService, + [FromServices] IRepository _studyMonitorRepository) + { + var savedInfo = _studyService.GetSaveToDicomInfo(preArchiveStudyCommand.SubjectVisitId); + + var studyMonitor = new StudyMonitor() + { + TrialId = savedInfo.TrialId, + SubjectId = savedInfo.SubjectId, + SubjectVisitId = savedInfo.SubjectVisitId, + + IsSuccess = false, + UploadStartTime = DateTime.Now, + IsDicom = preArchiveStudyCommand.IsDicom, + IP = _userInfo.IP + }; + + + var addEntity = await _studyMonitorRepository.AddAsync(studyMonitor, true); + + return ResponseOutput.Ok(addEntity.Id); + + } /// /// 上传非Dicom 文件 支持压缩包 多文件上传 /// @@ -1000,9 +1000,9 @@ namespace IRaCIS.Core.API.Controllers item.TrialSiteId = siteList.FirstOrDefault(t => t.TrialSiteCode.ToUpper() == item.TrialSiteCode.ToUpper()).TrialSiteId; } + var list = excelList.Where(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserTypeEnum == UserTypeEnum.CRA).ToList(); - - await _trialSiteSurveyService.ImportGenerateAccountAndJoinTrialAsync(trialId, baseUrl, routeUrl, excelList.ToList()); + await _trialSiteSurveyService.ImportGenerateAccountAndJoinTrialAsync(trialId, baseUrl, routeUrl, list); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index a3eb2f0fe..412809334 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -103,12 +103,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } [HttpGet] - public async Task DicomUploadInProgress(Guid trialId, string studyInstanceUid,Guid? visitTaskId) + public async Task DicomUploadInProgress(Guid trialId, string studyInstanceUid, Guid? visitTaskId) { - if(visitTaskId != null) + if (visitTaskId != null) { var cacheValue = _fusionCache.GetOrDefault(CacheKeys.TrialTaskStudyUidUploading(trialId, visitTaskId.Value, studyInstanceUid)); - if (cacheValue != Guid.Empty && cacheValue !=_userInfo.Id) + if (cacheValue != Guid.Empty && cacheValue != _userInfo.Id) { //---当前已有人正在上传和归档该检查! return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress")); @@ -134,11 +134,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] public async Task AddOrUpdateArchiveStudy(NewArchiveStudyCommand incommand) { - //总数为0的检查不允许提交 - if (incommand.Study.SeriesList.SelectMany(t => t.InstanceList).Count() == 0) - { - return ResponseOutput.NotOk("Study_InstanceCountZero"); - } + var @uploadLock = _distributedLockProvider.CreateLock($"UploadDicom"); @@ -163,7 +159,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var trialId = incommand.TrialId; - var studyMonitor = await _studyMonitorRepository.FirstOrDefaultAsync(t => t.Id == incommand.StudyMonitorId); studyMonitor.UploadFinishedTime = DateTime.Now; studyMonitor.ArchiveFinishedTime = DateTime.Now; @@ -171,10 +166,36 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc studyMonitor.IsSuccess = incommand.FailedFileCount == 0; studyMonitor.RecordPath = incommand.RecordPath; + var studyId = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString()); + var findStudy = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == studyId); + + studyMonitor.StudyId = studyId; + studyMonitor.StudyCode = findStudy?.StudyCode??""; + + + if (incommand.Study.SeriesList.SelectMany(t => t.InstanceList).Count() == 0) + { + await _studyMonitorRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + //上传 if (studyMonitor.IsDicomReUpload == false) { - var study = _mapper.Map(incommand.Study); + + //如果因为意外情况,连续点击两次,导致第一次插入了,第二次进来也会插入,在此判断一下 + if (findStudy != null) + { + + await _studyMonitorRepository.SaveChangesAsync(); + + //直接返回 + return ResponseOutput.Ok(); + } + + + var addStudy = _mapper.Map(incommand.Study); var @lock = _distributedLockProvider.CreateLock($"StudyCode"); @@ -188,42 +209,34 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc int currentNextCodeInt = cacheMaxCodeInt > dbStudyCodeIntMax ? cacheMaxCodeInt + 1 : dbStudyCodeIntMax + 1; - study.Code = currentNextCodeInt; + addStudy.Code = currentNextCodeInt; - study.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy)); + addStudy.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy)); - await _fusionCache.SetAsync(CacheKeys.TrialStudyMaxCode(trialId), study.Code, TimeSpan.FromMinutes(30)); + await _fusionCache.SetAsync(CacheKeys.TrialStudyMaxCode(trialId), addStudy.Code, TimeSpan.FromMinutes(30)); } - study.Id = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString()); - study.TrialId = incommand.TrialId; - study.SubjectId = incommand.SubjectId; - study.SubjectVisitId = incommand.SubjectVisitId; - study.IsFromPACS = false; + addStudy.Id = studyId; + addStudy.TrialId = incommand.TrialId; + addStudy.SubjectId = incommand.SubjectId; + addStudy.SubjectVisitId = incommand.SubjectVisitId; + addStudy.IsFromPACS = false; - //如果因为意外情况,连续点击两次,导致第一次插入了,第二次进来也会插入,在此判断一下 - var findStudy = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == study.Id); - - if (findStudy != null) - { - //直接返回 - return ResponseOutput.Ok(); - } //特殊处理逻辑 - study.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Distinct()); - SpecialArchiveStudyDeal(study); - modalitys = study.Modalities; + addStudy.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Distinct()); + SpecialArchiveStudyDeal(addStudy); + modalitys = addStudy.Modalities; - await _dicomstudyRepository.AddAsync(study); + await _dicomstudyRepository.AddAsync(addStudy); - studyMonitor.StudyId = study.Id; - studyMonitor.StudyCode = study.StudyCode; + + studyMonitor.StudyCode = addStudy.StudyCode; foreach (var seriesItem in incommand.Study.SeriesList) @@ -231,7 +244,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var series = _mapper.Map(seriesItem); series.Id = IdentifierHelper.CreateGuid(seriesItem.StudyInstanceUid, seriesItem.SeriesInstanceUid, incommand.TrialId.ToString()); - series.StudyId = study.Id; + series.StudyId = addStudy.Id; series.TrialId = incommand.TrialId; series.SubjectId = incommand.SubjectId; @@ -246,10 +259,10 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var isntance = _mapper.Map(instanceItem); - Guid instanceId = IdentifierHelper.CreateGuid(study.StudyInstanceUid, series.SeriesInstanceUid, isntance.SopInstanceUid, study.TrialId.ToString()); + Guid instanceId = IdentifierHelper.CreateGuid(addStudy.StudyInstanceUid, series.SeriesInstanceUid, isntance.SopInstanceUid, addStudy.TrialId.ToString()); isntance.Id = instanceId; - isntance.StudyId = study.Id; + isntance.StudyId = addStudy.Id; isntance.SeriesId = series.Id; isntance.TrialId = incommand.TrialId; @@ -260,26 +273,15 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } } - - - } else { - var studyId = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString()); ; - - var study = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == studyId); - - //重传的时候也要赋值检查Id - studyMonitor.StudyId = study.Id; - studyMonitor.StudyCode = study.StudyCode; - //特殊处理逻辑 - study.IsFromPACS = false; - study.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Union(study.Modalities.Split("、", StringSplitOptions.RemoveEmptyEntries)).Distinct()); - SpecialArchiveStudyDeal(study); - modalitys = study.Modalities; + findStudy.IsFromPACS = false; + findStudy.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Union(findStudy.Modalities.Split("、", StringSplitOptions.RemoveEmptyEntries)).Distinct()); + SpecialArchiveStudyDeal(findStudy); + modalitys = findStudy.Modalities; // 少了整个序列 @@ -297,7 +299,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var series = _mapper.Map(seriesItem); series.Id = seriesId; - series.StudyId = study.Id; + series.StudyId = findStudy.Id; series.TrialId = incommand.TrialId; series.SubjectId = incommand.SubjectId; @@ -307,7 +309,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc dicomSeries = await _dicomSeriesRepository.AddAsync(series); //新的序列 那么 检查的序列数量+1 - study.SeriesCount += 1; + findStudy.SeriesCount += 1; } else { @@ -319,7 +321,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var insntance = _mapper.Map(instanceItem); insntance.Id = IdentifierHelper.CreateGuid(insntance.StudyInstanceUid, insntance.SeriesInstanceUid, insntance.SopInstanceUid, trialId.ToString()); - insntance.StudyId = study.Id; + insntance.StudyId = findStudy.Id; insntance.SeriesId = dicomSeries.Id; insntance.TrialId = incommand.TrialId; @@ -331,7 +333,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc // 不管是新的序列 还是 该序列 掉了Instance 重传的时候 检查的instance 数量都会增加 - study.InstanceCount += seriesItem.InstanceList.Count; + findStudy.InstanceCount += seriesItem.InstanceList.Count; } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index ffef6f05a..63729ed88 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -934,6 +934,8 @@ namespace IRaCIS.Core.Application.Contracts saveItem.UserName = saveItem.UserCode; + //saveItem.UserTypeEnum = _userTypeRepository.Where(t => t.Id == saveItem.UserTypeId).Select(t => t.UserTypeEnum).First(); + var newUser = _userRepository.AddAsync(saveItem).Result; _ = _userRepository.SaveChangesAsync().Result; diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index ee4383ff0..a6483c556 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -251,10 +251,8 @@ namespace IRaCIS.Core.Application.Services HtmlPath = k.HtmlPath, Path = k.Path, InstanceNumber = k.InstanceNumber, - }).ToList(); } - ); //设置为阅片与否 不更改数据库检查 的instance数量 和 SeriesCount 所以这里要实时统计 diff --git a/IRaCIS.Core.Domain/Image/TrialImageDownload.cs b/IRaCIS.Core.Domain/Image/TrialImageDownload.cs index 12b65c1fa..72bacf5d0 100644 --- a/IRaCIS.Core.Domain/Image/TrialImageDownload.cs +++ b/IRaCIS.Core.Domain/Image/TrialImageDownload.cs @@ -44,7 +44,9 @@ namespace IRaCIS.Core.Domain.Models public enum ImageType { Dicom = 1, + NoneDicom = 2, + DicomAndNoneDicom = 3 }; } diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MaxStringLengthConvention .cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MaxStringLengthConvention .cs new file mode 100644 index 000000000..e15a8e573 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MaxStringLengthConvention .cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Conventions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test +{ + /// + /// Efcore 最新支持批量配置字符串类型长度作为保底的 官网参考:https://learn.microsoft.com/zh-cn/ef/core/modeling/bulk-configuration#conventions + /// + public class MaxStringLengthConvention : IModelFinalizingConvention + { + public void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + { + foreach (var property in modelBuilder.Metadata.GetEntityTypes() + .SelectMany( + entityType => entityType.GetDeclaredProperties() + .Where( + property => property.ClrType == typeof(string)))) + { + property.Builder.HasMaxLength(200); + } + } + } + +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MigrationRemoveForeignKeysSqlGenerator .cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MigrationRemoveForeignKeysSqlGenerator .cs new file mode 100644 index 000000000..dae427d53 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Convention/MigrationRemoveForeignKeysSqlGenerator .cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations.Operations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Convention +{ + public class MigrationRemoveForeignKeysSqlGenerator : MigrationsSqlGenerator + { + public MigrationRemoveForeignKeysSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IMigrationsAnnotationProvider migrationsAnnotations) : base(dependencies) + { + } + + protected override void Generate(Microsoft.EntityFrameworkCore.Migrations.Operations.CreateTableOperation operation, IModel? model, MigrationCommandListBuilder builder, bool terminate = true) + { + operation.ForeignKeys.Clear(); + base.Generate(operation, model, builder, terminate); + } + + protected override void Generate(AddForeignKeyOperation operation, IModel? model, MigrationCommandListBuilder builder, + bool terminate = true) + { + return; + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs index 099056b6f..d8c0ed818 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/IRCContext.cs @@ -3,7 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL.Convention; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.Extensions.Options; namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL; @@ -30,8 +33,20 @@ public partial class IRCContext : DbContext public virtual DbSet ReadingClinicalData { get; set; } public virtual DbSet ReadModule { get; set; } + public virtual DbSet TestStringLength { get; set; } + + public virtual DbSet Project { get; set; } + + public virtual DbSet ProjectUser { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true"); + { + optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true"); + + //移除外键约束 + optionsBuilder.ReplaceService(); + } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -43,9 +58,15 @@ public partial class IRCContext : DbContext modelBuilder.ApplyConfiguration(configurationInstance); } + OnModelCreatingPartial(modelBuilder); } + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) + { + //针对字符串使用默认的长度配置 + configurationBuilder.Conventions.Add(_ => new MaxStringLengthConvention()); + } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); } diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.Designer.cs new file mode 100644 index 000000000..6afdc346a --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.Designer.cs @@ -0,0 +1,356 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240911143331_testMaxLength")] + partial class testMaxLength + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("ReadModule"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReadingId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ReadingId"); + + b.ToTable("ReadingClinicalData"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", "ReadModule") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "SubjectVisit") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReadModule"); + + b.Navigation("SubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.cs new file mode 100644 index 000000000..420938bec --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911143331_testMaxLength.cs @@ -0,0 +1,111 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class testMaxLength : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Name", + table: "Subject", + type: "nvarchar(200)", + maxLength: 200, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Code", + table: "Dictionary", + type: "nvarchar(200)", + maxLength: 200, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.CreateTable( + name: "ReadModule", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ReadModule", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ReadingClinicalData", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ReadingId = table.Column(type: "uniqueidentifier", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ReadingClinicalData", x => x.Id); + table.ForeignKey( + name: "FK_ReadingClinicalData_ReadModule_ReadingId", + column: x => x.ReadingId, + principalTable: "ReadModule", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ReadingClinicalData_SubejectVisit_ReadingId", + column: x => x.ReadingId, + principalTable: "SubejectVisit", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ReadingClinicalData_ReadingId", + table: "ReadingClinicalData", + column: "ReadingId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ReadingClinicalData"); + + migrationBuilder.DropTable( + name: "ReadModule"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Subject", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(200)", + oldMaxLength: 200); + + migrationBuilder.AlterColumn( + name: "Code", + table: "Dictionary", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(200)", + oldMaxLength: 200); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.Designer.cs new file mode 100644 index 000000000..55e35c9f0 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.Designer.cs @@ -0,0 +1,394 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240911144206_teststr")] + partial class teststr + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("ReadModule"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReadingId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ReadingId"); + + b.ToTable("ReadingClinicalData"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestStringLength", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DefaultLength") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserDefineLength") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserDefineText") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("TestStringLength"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", "ReadModule") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "SubjectVisit") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReadModule"); + + b.Navigation("SubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.cs new file mode 100644 index 000000000..f479cf60c --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911144206_teststr.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class teststr : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "TestStringLength", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DefaultLength = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + UserDefineLength = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + UserDefineText = table.Column(type: "text", maxLength: 200, nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TestStringLength", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TestStringLength"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.Designer.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.Designer.cs new file mode 100644 index 000000000..86afc5129 --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.Designer.cs @@ -0,0 +1,456 @@ +// +using System; +using IRaCIS.Core.Test.CodeFirstTest.MSSQL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + [DbContext(typeof(IRCContext))] + [Migration("20240911151956_RemoveForeignKeys")] + partial class RemoveForeignKeys + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ConfigTypeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ConfigTypeId"); + + b.HasIndex("ParentId"); + + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Project"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ProjectUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.ToTable("ProjectUser"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("ReadModule"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReadingId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ReadingId"); + + b.ToTable("ReadingClinicalData"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SubjectId"); + + b.ToTable("SubejectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("FinalSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("LatestSubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("FinalSubjectVisitId"); + + b.HasIndex("LatestSubjectVisitId"); + + b.ToTable("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("TrialImageDownloadId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TrialImageDownloadId"); + + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestStringLength", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DefaultLength") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserDefineLength") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserDefineText") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("TestStringLength"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DownloadEndTime") + .HasColumnType("datetime2"); + + b.Property("DownloadStartTime") + .HasColumnType("datetime2"); + + b.Property("ImageCount") + .HasColumnType("int"); + + b.Property("ImageSize") + .HasColumnType("bigint"); + + b.Property("ImageType") + .HasColumnType("int"); + + b.Property("IsSuccess") + .HasColumnType("bit"); + + b.Property("SubjectVisitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TrialImageDownload"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType") + .WithMany() + .HasForeignKey("ConfigTypeId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent") + .WithMany("ChildList") + .HasForeignKey("ParentId"); + + b.Navigation("ConfigType"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ProjectUser", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", "ReadModule") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "SubjectVisit") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReadModule"); + + b.Navigation("SubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") + .WithMany("SubejectVisitList") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit") + .WithMany() + .HasForeignKey("FinalSubjectVisitId"); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit") + .WithMany() + .HasForeignKey("LatestSubjectVisitId"); + + b.Navigation("FinalSubjectVisit"); + + b.Navigation("LatestSubjectVisit"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null) + .WithMany("TestNewList") + .HasForeignKey("TrialImageDownloadId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => + { + b.Navigation("ChildList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => + { + b.Navigation("SubejectVisitList"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => + { + b.Navigation("TestNewList"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.cs new file mode 100644 index 000000000..8a67fbd0e --- /dev/null +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240911151956_RemoveForeignKeys.cs @@ -0,0 +1,67 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations +{ + /// + public partial class RemoveForeignKeys : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Project", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Project", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ProjectUser", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ProjectId = table.Column(type: "uniqueidentifier", nullable: false), + CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreateTime = table.Column(type: "datetime2", nullable: false), + UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), + UpdateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProjectUser", x => x.Id); + table.ForeignKey( + name: "FK_ProjectUser_Project_ProjectId", + column: x => x.ProjectId, + principalTable: "Project", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ProjectUser_ProjectId", + table: "ProjectUser", + column: "ProjectId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ProjectUser"); + + migrationBuilder.DropTable( + name: "Project"); + } + } +} diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs index ffb12bafa..8a0151aca 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/IRCContextModelSnapshot.cs @@ -25,11 +25,13 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("Code") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ConfigTypeId") .HasColumnType("uniqueidentifier"); @@ -55,12 +57,125 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasIndex("ParentId"); - b.ToTable("Dictionary", (string)null); + b.ToTable("Dictionary"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("Project"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ProjectUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.ToTable("ProjectUser"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("ReadModule"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReadingId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ReadingId"); + + b.ToTable("ReadingClinicalData"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("CreateTime") @@ -82,12 +197,13 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasIndex("SubjectId"); - b.ToTable("SubejectVisit", (string)null); + b.ToTable("SubejectVisit"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("CreateTime") @@ -104,7 +220,8 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("UpdateTime") .HasColumnType("datetime2"); @@ -118,12 +235,13 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasIndex("LatestSubjectVisitId"); - b.ToTable("Subject", (string)null); + b.ToTable("Subject"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("CreateTime") @@ -150,12 +268,51 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasIndex("TrialImageDownloadId"); - b.ToTable("TestNew", (string)null); + b.ToTable("TestNew"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestStringLength", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreateTime") + .HasColumnType("datetime2"); + + b.Property("CreateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DefaultLength") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UpdateTime") + .HasColumnType("datetime2"); + + b.Property("UpdateUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserDefineLength") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserDefineText") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("TestStringLength"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); b.Property("CreateTime") @@ -193,7 +350,7 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.HasKey("Id"); - b.ToTable("TrialImageDownload", (string)null); + b.ToTable("TrialImageDownload"); }); modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b => @@ -211,6 +368,36 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations b.Navigation("Parent"); }); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ProjectUser", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadingClinicalData", b => + { + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.ReadModule", "ReadModule") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "SubjectVisit") + .WithMany() + .HasForeignKey("ReadingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReadModule"); + + b.Navigation("SubjectVisit"); + }); + modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b => { b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject") diff --git a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs index 02eee8fe9..6410bc381 100644 --- a/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs +++ b/IRaCIS.Core.Test/CodeFirstTest/MSSQL/TrialImageDownload.cs @@ -1,6 +1,4 @@ -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Domain.Share; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -10,6 +8,15 @@ using System.Threading.Tasks; namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL { + public abstract class BaseFullAuditEntity + { + [Key] + public Guid Id { get; set; } + public Guid CreateUserId { get; set; } + public DateTime CreateTime { get; set; } + public Guid UpdateUserId { get; set; } + public DateTime UpdateTime { get; set; } + } [Table("TrialImageDownload")] public class TrialImageDownload : BaseFullAuditEntity @@ -126,6 +133,34 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL } #endregion + #region 测试 字符串默认长度配置 + public class TestStringLength : BaseFullAuditEntity + { + public string DefaultLength { get; set; } + [MaxLength(300)] + public string UserDefineLength { get; set; } + + [Column(TypeName = "text")] + public string UserDefineText { get; set; } + + } + #endregion + + #region 测试生成迁移移除外键约束 + + #endregion + public class Project : BaseFullAuditEntity + { + + } + + public class ProjectUser: BaseFullAuditEntity + { + //外键 + public Guid ProjectId { get; set; } + + public Project Project { get; set; } + } }