From 6a2b4a597095e9e792d463f84e556d1240d56d7f Mon Sep 17 00:00:00 2001 From: Alek-ban Date: Mon, 15 Dec 2025 15:29:52 +0300 Subject: [PATCH] feat: migrations update Added tool for migrations Updated AmineContentCalibration db Create AmineContentResults db --- .../AmineContentCalibrationDataService.cs | 17 +- .../AmineContentResultsDataService.cs | 21 +++ ...mineContentCalibrationInitial.Designer.cs} | 4 +- ...8044919_AmineContentCalibrationInitial.cs} | 2 +- ...924_AmineContentResultsInitial.Designer.cs | 167 ++++++++++++++++++ ...251208044924_AmineContentResultsInitial.cs | 126 +++++++++++++ .../AmineContentCalibrationContextFactory.cs | 3 +- .../Database/AmineContentResultsContext.cs | 70 ++++++++ .../AmineContentResultsContextFactory.cs | 18 ++ ...AmineContentResultsContextModelSnapshot.cs | 164 +++++++++++++++++ GSS2.Core/tools/CreateMigrations.ps1 | 2 + 11 files changed, 589 insertions(+), 5 deletions(-) create mode 100644 GSS2.Core/Analysis/AmineContent/AmineContentResultsDataService.cs rename GSS2.Core/Analysis/AmineContent/Database/{20251125054200_Initial.Designer.cs => 20251208044919_AmineContentCalibrationInitial.Designer.cs} (98%) rename GSS2.Core/Analysis/AmineContent/Database/{20251125054200_Initial.cs => 20251208044919_AmineContentCalibrationInitial.cs} (99%) create mode 100644 GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.Designer.cs create mode 100644 GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.cs create mode 100644 GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContext.cs create mode 100644 GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextFactory.cs create mode 100644 GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextModelSnapshot.cs create mode 100644 GSS2.Core/tools/CreateMigrations.ps1 diff --git a/GSS2.Core/Analysis/AmineContent/AmineContentCalibrationDataService.cs b/GSS2.Core/Analysis/AmineContent/AmineContentCalibrationDataService.cs index 9c95910..d78c069 100644 --- a/GSS2.Core/Analysis/AmineContent/AmineContentCalibrationDataService.cs +++ b/GSS2.Core/Analysis/AmineContent/AmineContentCalibrationDataService.cs @@ -1,6 +1,21 @@ +using GSS2.Core.Analysis.AmineContent.Database; +using Microsoft.Extensions.Logging; + namespace GSS2.Core.Analysis.AmineContent; public class AmineContentCalibrationDataService { - + private readonly ILogger _logger; + private AmineContentCalibrationContext _calibrationContext; + + public AmineContentCalibrationDataService(ILogger logger, AmineContentCalibrationContext calibrationContext) + { + _logger = logger; + _calibrationContext = calibrationContext; + } + + public async Task LoadData(CancellationToken cancellationToken = default) + { + //TODO + } } \ No newline at end of file diff --git a/GSS2.Core/Analysis/AmineContent/AmineContentResultsDataService.cs b/GSS2.Core/Analysis/AmineContent/AmineContentResultsDataService.cs new file mode 100644 index 0000000..7ea58c9 --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/AmineContentResultsDataService.cs @@ -0,0 +1,21 @@ +using GSS2.Core.Analysis.AmineContent.Database; +using Microsoft.Extensions.Logging; + +namespace GSS2.Core.Analysis.AmineContent; + +public class AmineContentResultsDataService +{ + private readonly ILogger _logger; + private AmineContentCalibrationContext _calibrationContext; + + public AmineContentResultsDataService(ILogger logger, AmineContentCalibrationContext calibrationContext) + { + _logger = logger; + _calibrationContext = calibrationContext; + } + + public async Task LoadData(CancellationToken cancellationToken = default) + { + //TODO + } +} \ No newline at end of file diff --git a/GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.Designer.cs b/GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.Designer.cs similarity index 98% rename from GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.Designer.cs rename to GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.Designer.cs index e858fb4..053ce41 100644 --- a/GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.Designer.cs +++ b/GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace GSS2.Core.Analysis.AmineContent.Database { [DbContext(typeof(AmineContentCalibrationContext))] - [Migration("20251125054200_Initial")] - partial class Initial + [Migration("20251208044919_AmineContentCalibrationInitial")] + partial class AmineContentCalibrationInitial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.cs b/GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.cs similarity index 99% rename from GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.cs rename to GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.cs index 5782027..ca2fd83 100644 --- a/GSS2.Core/Analysis/AmineContent/Database/20251125054200_Initial.cs +++ b/GSS2.Core/Analysis/AmineContent/Database/20251208044919_AmineContentCalibrationInitial.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace GSS2.Core.Analysis.AmineContent.Database { /// - public partial class Initial : Migration + public partial class AmineContentCalibrationInitial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.Designer.cs b/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.Designer.cs new file mode 100644 index 0000000..df543f1 --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.Designer.cs @@ -0,0 +1,167 @@ +// +using System; +using GSS2.Core.Analysis.AmineContent.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace GSS2.Core.Analysis.AmineContent.Database +{ + [DbContext(typeof(AmineContentResultsContext))] + [Migration("20251208044924_AmineContentResultsInitial")] + partial class AmineContentResultsInitial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.0"); + + modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasComment("Уникальный идентификатор"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Путь к файлу изображения"); + + b.Property("ImageType") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Тип изображения (sample - проба или separator - сепаратор)"); + + b.Property("Uv254Intensity") + .HasColumnType("REAL") + .HasComment("Интенсивность УФ излучения 254 нм (0..1)"); + + b.Property("Uv365Intensity") + .HasColumnType("REAL") + .HasComment("Интенсивность УФ излучения 365 нм (0..1)"); + + b.Property("VisibleIntensity") + .HasColumnType("REAL") + .HasComment("Интенсивность видимого света (0..1)"); + + b.HasKey("Id"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasComment("Уникальный идентификатор"); + + b.Property("AirHumidity") + .HasColumnType("REAL") + .HasComment("Относительная влажность воздуха (%)"); + + b.Property("AirTemperature") + .HasColumnType("REAL") + .HasComment("Температура воздуха (℃)"); + + b.Property("SampleBrand") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Марка пробы"); + + b.Property("SampleComment") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Дополнительная информация о пробе"); + + b.Property("SampleMass") + .HasColumnType("REAL") + .HasComment("Масса пробы (кг)"); + + b.Property("SampleName") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Название пробы"); + + b.Property("SamplingDateTime") + .HasColumnType("TEXT") + .HasComment("Дата и время отбора пробы"); + + b.Property("SamplingPlace") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Место отбора пробы"); + + b.HasKey("Id"); + + b.ToTable("Records"); + }); + + modelBuilder.Entity("ImageDataRecord", b => + { + b.Property("SampleImagesId") + .HasColumnType("INTEGER"); + + b.Property("SampleRecordsId") + .HasColumnType("INTEGER"); + + b.HasKey("SampleImagesId", "SampleRecordsId"); + + b.HasIndex("SampleRecordsId"); + + b.ToTable("SampleImages", (string)null); + }); + + modelBuilder.Entity("ImageDataRecord1", b => + { + b.Property("SeparatorImagesId") + .HasColumnType("INTEGER"); + + b.Property("SeparatorRecordsId") + .HasColumnType("INTEGER"); + + b.HasKey("SeparatorImagesId", "SeparatorRecordsId"); + + b.HasIndex("SeparatorRecordsId"); + + b.ToTable("SeparatorImages", (string)null); + }); + + modelBuilder.Entity("ImageDataRecord", b => + { + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", null) + .WithMany() + .HasForeignKey("SampleImagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", null) + .WithMany() + .HasForeignKey("SampleRecordsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ImageDataRecord1", b => + { + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", null) + .WithMany() + .HasForeignKey("SeparatorImagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", null) + .WithMany() + .HasForeignKey("SeparatorRecordsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.cs b/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.cs new file mode 100644 index 0000000..c68b0be --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/Database/20251208044924_AmineContentResultsInitial.cs @@ -0,0 +1,126 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GSS2.Core.Analysis.AmineContent.Database +{ + /// + public partial class AmineContentResultsInitial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Images", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false, comment: "Уникальный идентификатор") + .Annotation("Sqlite:Autoincrement", true), + VisibleIntensity = table.Column(type: "REAL", nullable: false, comment: "Интенсивность видимого света (0..1)"), + Uv365Intensity = table.Column(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 365 нм (0..1)"), + Uv254Intensity = table.Column(type: "REAL", nullable: false, comment: "Интенсивность УФ излучения 254 нм (0..1)"), + ImageType = table.Column(type: "TEXT", nullable: false, comment: "Тип изображения (sample - проба или separator - сепаратор)"), + ImagePath = table.Column(type: "TEXT", nullable: false, comment: "Путь к файлу изображения") + }, + constraints: table => + { + table.PrimaryKey("PK_Images", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Records", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false, comment: "Уникальный идентификатор") + .Annotation("Sqlite:Autoincrement", true), + SampleName = table.Column(type: "TEXT", nullable: false, comment: "Название пробы"), + SampleComment = table.Column(type: "TEXT", nullable: false, comment: "Дополнительная информация о пробе"), + SampleBrand = table.Column(type: "TEXT", nullable: false, comment: "Марка пробы"), + SampleMass = table.Column(type: "REAL", nullable: false, comment: "Масса пробы (кг)"), + SamplingDateTime = table.Column(type: "TEXT", nullable: false, comment: "Дата и время отбора пробы"), + SamplingPlace = table.Column(type: "TEXT", nullable: false, comment: "Место отбора пробы"), + AirTemperature = table.Column(type: "REAL", nullable: false, comment: "Температура воздуха (℃)"), + AirHumidity = table.Column(type: "REAL", nullable: false, comment: "Относительная влажность воздуха (%)") + }, + constraints: table => + { + table.PrimaryKey("PK_Records", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SampleImages", + columns: table => new + { + SampleImagesId = table.Column(type: "INTEGER", nullable: false), + SampleRecordsId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SampleImages", x => new { x.SampleImagesId, x.SampleRecordsId }); + table.ForeignKey( + name: "FK_SampleImages_Images_SampleImagesId", + column: x => x.SampleImagesId, + principalTable: "Images", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SampleImages_Records_SampleRecordsId", + column: x => x.SampleRecordsId, + principalTable: "Records", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SeparatorImages", + columns: table => new + { + SeparatorImagesId = table.Column(type: "INTEGER", nullable: false), + SeparatorRecordsId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SeparatorImages", x => new { x.SeparatorImagesId, x.SeparatorRecordsId }); + table.ForeignKey( + name: "FK_SeparatorImages_Images_SeparatorImagesId", + column: x => x.SeparatorImagesId, + principalTable: "Images", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SeparatorImages_Records_SeparatorRecordsId", + column: x => x.SeparatorRecordsId, + principalTable: "Records", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_SampleImages_SampleRecordsId", + table: "SampleImages", + column: "SampleRecordsId"); + + migrationBuilder.CreateIndex( + name: "IX_SeparatorImages_SeparatorRecordsId", + table: "SeparatorImages", + column: "SeparatorRecordsId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SampleImages"); + + migrationBuilder.DropTable( + name: "SeparatorImages"); + + migrationBuilder.DropTable( + name: "Images"); + + migrationBuilder.DropTable( + name: "Records"); + } + } +} diff --git a/GSS2.Core/Analysis/AmineContent/Database/AmineContentCalibrationContextFactory.cs b/GSS2.Core/Analysis/AmineContent/Database/AmineContentCalibrationContextFactory.cs index eee2a4b..95d0588 100644 --- a/GSS2.Core/Analysis/AmineContent/Database/AmineContentCalibrationContextFactory.cs +++ b/GSS2.Core/Analysis/AmineContent/Database/AmineContentCalibrationContextFactory.cs @@ -9,7 +9,8 @@ public class AmineContentCalibrationContextFactory : IDesignTimeDbContextFactory { var optionsBuilder = new DbContextOptionsBuilder(); - // строка подключения для миграций (в design-time) + // Строка подключения для миграций в design-time + // в runtime должна использоваться настоящая ConnectionString optionsBuilder.UseSqlite("Data Source=AmineContentCalibration.db"); return new AmineContentCalibrationContext(optionsBuilder.Options); diff --git a/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContext.cs b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContext.cs new file mode 100644 index 0000000..5afde37 --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContext.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore; + +namespace GSS2.Core.Analysis.AmineContent.Database; + +public class AmineContentResultsContext : DbContext +{ + public class Record + { + [Comment("Уникальный идентификатор")] + public int Id { get; set; } + [Comment("Название пробы")] + public string SampleName { get; set; } = string.Empty; + [Comment("Дополнительная информация о пробе")] + public string SampleComment { get; set; } = string.Empty; + [Comment("Марка пробы")] + public string SampleBrand { get; set; } = string.Empty; + [Comment("Масса пробы (кг)")] + public double SampleMass { get; set; } = double.NaN; + [Comment("Дата и время отбора пробы")] + public DateTime SamplingDateTime { get; set; } = DateTime.Now; + [Comment("Место отбора пробы")] + public string SamplingPlace { get; set; } = string.Empty; + [Comment("Изображения пробы")] + public List SampleImages { get; set; } = new(); + [Comment("Изображения пустого сепаратора")] + public List SeparatorImages { get; set; } = new(); + [Comment("Температура воздуха (℃)")] + public double AirTemperature { get; set; } = new(); + [Comment("Относительная влажность воздуха (%)")] + public double AirHumidity { get; set; } = new(); + } + public class ImageData + { + [Comment("Уникальный идентификатор")] + public int Id { get; set; } + [Comment("Интенсивность видимого света (0..1)")] + public double VisibleIntensity { get; set; } = double.NaN; + [Comment("Интенсивность УФ излучения 365 нм (0..1)")] + public double Uv365Intensity { get; set; } = double.NaN; + [Comment("Интенсивность УФ излучения 254 нм (0..1)")] + public double Uv254Intensity { get; set; } = double.NaN; + [Comment("Тип изображения (sample - проба или separator - сепаратор)")] + public string ImageType { get; set; } = string.Empty; + [Comment("Путь к файлу изображения")] + public string ImagePath { get; set; } = string.Empty; + + [Comment("Записи в которых это изображение используется как изображение пробы")] + public List SampleRecords { get; set; } = new(); + [Comment("Записи в которых это изображение используется как изображение сепаратора")] + public List SeparatorRecords { get; set; } = new(); + } + + public DbSet Records => Set(); + public DbSet Images => Set(); + + public AmineContentResultsContext(DbContextOptions options) : base(options) { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasMany(r => r.SampleImages) + .WithMany(i => i.SampleRecords) + .UsingEntity(j => j.ToTable("SampleImages")); + + modelBuilder.Entity() + .HasMany(r => r.SeparatorImages) + .WithMany(i => i.SeparatorRecords) + .UsingEntity(j => j.ToTable("SeparatorImages")); + } +} \ No newline at end of file diff --git a/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextFactory.cs b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextFactory.cs new file mode 100644 index 0000000..7f7c89e --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextFactory.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; + +namespace GSS2.Core.Analysis.AmineContent.Database; + +public class AmineContentResultsContextFactory : IDesignTimeDbContextFactory +{ + public AmineContentResultsContext CreateDbContext(string[] args) + { + var optionsBuilder = new DbContextOptionsBuilder(); + + // Строка подключения для миграций в design-time + // в runtime должна использоваться настоящая ConnectionString + optionsBuilder.UseSqlite("Data Source=AmineContentResults.db"); + + return new AmineContentResultsContext(optionsBuilder.Options); + } +} diff --git a/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextModelSnapshot.cs b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextModelSnapshot.cs new file mode 100644 index 0000000..5e703f9 --- /dev/null +++ b/GSS2.Core/Analysis/AmineContent/Database/AmineContentResultsContextModelSnapshot.cs @@ -0,0 +1,164 @@ +// +using System; +using GSS2.Core.Analysis.AmineContent.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace GSS2.Core.Analysis.AmineContent.Database +{ + [DbContext(typeof(AmineContentResultsContext))] + partial class AmineContentResultsContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.0"); + + modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasComment("Уникальный идентификатор"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Путь к файлу изображения"); + + b.Property("ImageType") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Тип изображения (sample - проба или separator - сепаратор)"); + + b.Property("Uv254Intensity") + .HasColumnType("REAL") + .HasComment("Интенсивность УФ излучения 254 нм (0..1)"); + + b.Property("Uv365Intensity") + .HasColumnType("REAL") + .HasComment("Интенсивность УФ излучения 365 нм (0..1)"); + + b.Property("VisibleIntensity") + .HasColumnType("REAL") + .HasComment("Интенсивность видимого света (0..1)"); + + b.HasKey("Id"); + + b.ToTable("Images"); + }); + + modelBuilder.Entity("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasComment("Уникальный идентификатор"); + + b.Property("AirHumidity") + .HasColumnType("REAL") + .HasComment("Относительная влажность воздуха (%)"); + + b.Property("AirTemperature") + .HasColumnType("REAL") + .HasComment("Температура воздуха (℃)"); + + b.Property("SampleBrand") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Марка пробы"); + + b.Property("SampleComment") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Дополнительная информация о пробе"); + + b.Property("SampleMass") + .HasColumnType("REAL") + .HasComment("Масса пробы (кг)"); + + b.Property("SampleName") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Название пробы"); + + b.Property("SamplingDateTime") + .HasColumnType("TEXT") + .HasComment("Дата и время отбора пробы"); + + b.Property("SamplingPlace") + .IsRequired() + .HasColumnType("TEXT") + .HasComment("Место отбора пробы"); + + b.HasKey("Id"); + + b.ToTable("Records"); + }); + + modelBuilder.Entity("ImageDataRecord", b => + { + b.Property("SampleImagesId") + .HasColumnType("INTEGER"); + + b.Property("SampleRecordsId") + .HasColumnType("INTEGER"); + + b.HasKey("SampleImagesId", "SampleRecordsId"); + + b.HasIndex("SampleRecordsId"); + + b.ToTable("SampleImages", (string)null); + }); + + modelBuilder.Entity("ImageDataRecord1", b => + { + b.Property("SeparatorImagesId") + .HasColumnType("INTEGER"); + + b.Property("SeparatorRecordsId") + .HasColumnType("INTEGER"); + + b.HasKey("SeparatorImagesId", "SeparatorRecordsId"); + + b.HasIndex("SeparatorRecordsId"); + + b.ToTable("SeparatorImages", (string)null); + }); + + modelBuilder.Entity("ImageDataRecord", b => + { + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", null) + .WithMany() + .HasForeignKey("SampleImagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", null) + .WithMany() + .HasForeignKey("SampleRecordsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ImageDataRecord1", b => + { + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+ImageData", null) + .WithMany() + .HasForeignKey("SeparatorImagesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GSS2.Core.Analysis.AmineContent.Database.AmineContentResultsContext+Record", null) + .WithMany() + .HasForeignKey("SeparatorRecordsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GSS2.Core/tools/CreateMigrations.ps1 b/GSS2.Core/tools/CreateMigrations.ps1 new file mode 100644 index 0000000..408ee8c --- /dev/null +++ b/GSS2.Core/tools/CreateMigrations.ps1 @@ -0,0 +1,2 @@ +dotnet ef migrations add -o .\Analysis\AmineContent\Database --project .\GSS2.Core\ AmineContentCalibrationInitial --context AmineContentCalibrationContext +dotnet ef migrations add -o .\Analysis\AmineContent\Database --project .\GSS2.Core\ AmineContentResultsInitial --context AmineContentResultsContext \ No newline at end of file