Add MetaData Table From ExistData

Change to use MySQL
This commit is contained in:
Suphonchai Phoonsawat 2023-06-26 14:02:04 +07:00
parent 89de09d213
commit a0b3b13074
136 changed files with 3438 additions and 1237 deletions

View file

@ -17,6 +17,8 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Oracle.EntityFrameworkCore" Version="7.21.9" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
</ItemGroup>
<ItemGroup>

View file

@ -11,34 +11,20 @@ namespace BMA.EHR.Infrastructure
public static IServiceCollection AddPersistence(this IServiceCollection services,
IConfiguration configuration)
{
services.AddDbContext<ApplicationDBContext>(options =>
options.UseOracle(configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly(typeof(ApplicationDBContext).Assembly.FullName)), ServiceLifetime.Transient);
var connectionString = configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<ApplicationDBContext>(options =>
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString),
b =>
{
b.MigrationsAssembly(typeof(ApplicationDBContext).Assembly.FullName);
b.MigrationsHistoryTable("__EHRMigrationsHistory");
}),
ServiceLifetime.Transient);
services.AddScoped<IApplicationDBContext>(provider => provider.GetService<ApplicationDBContext>());
return services;
}
public static IServiceCollection AddEmailSender(this IServiceCollection services,
IConfiguration configuration)
{
return services;
}
public static IServiceCollection AddS3Storage(this IServiceCollection services,
IConfiguration configuration)
{
return services;
}

View file

@ -1,376 +0,0 @@
// <auto-generated />
using System;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Oracle.EntityFrameworkCore.Metadata;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20230625113156_Init Project")]
partial class InitProject
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupDraftEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(899)
.HasComment("สถานะการเผยแพร่ข้อมูล");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(2)
.HasColumnType("NVARCHAR2(2)")
.HasColumnOrder(1)
.HasComment("ชื่อหมู่โลหิต");
b.HasKey("Id");
b.ToTable("MD_BloodGroup_Drafts");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(2)
.HasColumnType("NVARCHAR2(2)")
.HasColumnOrder(1)
.HasComment("ชื่อหมู่โลหิต");
b.HasKey("Id");
b.ToTable("MD_BloodGroups");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupPublishHistoryEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(1)
.HasComment("รายละเอียดการแก้ไข");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("ObjectValue")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(2)
.HasComment("เก็บ Object ที่มีการอัพเดตในระบบ");
b.HasKey("Id");
b.ToTable("MD_BloodGroup_Histories");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixDraftEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(899)
.HasComment("สถานะการเผยแพร่ข้อมูล");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("NVARCHAR2(100)")
.HasColumnOrder(1)
.HasComment("รายละเอียดคำนำหน้า");
b.HasKey("Id");
b.ToTable("MD_Prefix_Drafts");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("NVARCHAR2(100)")
.HasColumnOrder(1)
.HasComment("รายละเอียดคำนำหน้า");
b.HasKey("Id");
b.ToTable("MD_Prefixes");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixPublishHistoryEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(1)
.HasComment("รายละเอียดการแก้ไข");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("ObjectValue")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(2)
.HasComment("เก็บ Object ที่มีการอัพเดตในระบบ");
b.HasKey("Id");
b.ToTable("MD_Prefix_Histories");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,153 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitProject : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "MD_BloodGroup_Drafts",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Name = table.Column<string>(type: "NVARCHAR2(2)", maxLength: 2, nullable: false, comment: "ชื่อหมู่โลหิต"),
IsPublished = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการเผยแพร่ข้อมูล"),
IsActive = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_BloodGroup_Drafts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MD_BloodGroup_Histories",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Detail = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "รายละเอียดการแก้ไข"),
ObjectValue = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "เก็บ Object ที่มีการอัพเดตในระบบ"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_BloodGroup_Histories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MD_BloodGroups",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Name = table.Column<string>(type: "NVARCHAR2(2)", maxLength: 2, nullable: false, comment: "ชื่อหมู่โลหิต"),
IsActive = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_BloodGroups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MD_Prefix_Drafts",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Name = table.Column<string>(type: "NVARCHAR2(100)", maxLength: 100, nullable: false, comment: "รายละเอียดคำนำหน้า"),
IsPublished = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการเผยแพร่ข้อมูล"),
IsActive = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_Prefix_Drafts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MD_Prefix_Histories",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Detail = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "รายละเอียดการแก้ไข"),
ObjectValue = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "เก็บ Object ที่มีการอัพเดตในระบบ"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_Prefix_Histories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MD_Prefixes",
columns: table => new
{
Id = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "คีย์หลัก"),
Name = table.Column<string>(type: "NVARCHAR2(100)", maxLength: 100, nullable: false, comment: "รายละเอียดคำนำหน้า"),
IsActive = table.Column<bool>(type: "NUMBER(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedUserId = table.Column<Guid>(type: "RAW(16)", nullable: false, comment: "User Id ที่สร้างข้อมูล"),
CreatedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล"),
CreatedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
ModifiedUserId = table.Column<Guid>(type: "RAW(16)", nullable: true, comment: "User Id ที่แก้ไขข้อมูล"),
ModifiedUserFullName = table.Column<string>(type: "NVARCHAR2(2000)", nullable: true, comment: "ชื่อ User ที่แก้ไขข้อมูล"),
ModifiedDate = table.Column<DateTime>(type: "TIMESTAMP(7)", nullable: true, comment: "แก้ไขข้อมูลเมื่อ")
},
constraints: table =>
{
table.PrimaryKey("PK_MD_Prefixes", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MD_BloodGroup_Drafts");
migrationBuilder.DropTable(
name: "MD_BloodGroup_Histories");
migrationBuilder.DropTable(
name: "MD_BloodGroups");
migrationBuilder.DropTable(
name: "MD_Prefix_Drafts");
migrationBuilder.DropTable(
name: "MD_Prefix_Histories");
migrationBuilder.DropTable(
name: "MD_Prefixes");
}
}
}

View file

@ -0,0 +1,26 @@
// <auto-generated />
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
[DbContext(typeof(ApplicationDBContext))]
[Migration("20230626063110_Init MetaData Table")]
partial class InitMetaDataTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitMetaDataTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View file

@ -1,10 +1,8 @@
// <auto-generated />
using System;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Oracle.EntityFrameworkCore.Metadata;
#nullable disable
@ -18,355 +16,7 @@ namespace BMA.EHR.Infrastructure.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupDraftEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(899)
.HasComment("สถานะการเผยแพร่ข้อมูล");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(2)
.HasColumnType("NVARCHAR2(2)")
.HasColumnOrder(1)
.HasComment("ชื่อหมู่โลหิต");
b.HasKey("Id");
b.ToTable("MD_BloodGroup_Drafts");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(2)
.HasColumnType("NVARCHAR2(2)")
.HasColumnOrder(1)
.HasComment("ชื่อหมู่โลหิต");
b.HasKey("Id");
b.ToTable("MD_BloodGroups");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.BloodGroup.BloodGroupPublishHistoryEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(1)
.HasComment("รายละเอียดการแก้ไข");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("ObjectValue")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(2)
.HasComment("เก็บ Object ที่มีการอัพเดตในระบบ");
b.HasKey("Id");
b.ToTable("MD_BloodGroup_Histories");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixDraftEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<bool>("IsPublished")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(899)
.HasComment("สถานะการเผยแพร่ข้อมูล");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("NVARCHAR2(100)")
.HasColumnOrder(1)
.HasComment("รายละเอียดคำนำหน้า");
b.HasKey("Id");
b.ToTable("MD_Prefix_Drafts");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsActive")
.HasColumnType("NUMBER(1)")
.HasColumnOrder(990)
.HasComment("สถานะการใช้งาน");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("NVARCHAR2(100)")
.HasColumnOrder(1)
.HasComment("รายละเอียดคำนำหน้า");
b.HasKey("Id");
b.ToTable("MD_Prefixes");
});
modelBuilder.Entity("BMA.EHR.Domain.Entities.MetaData.Prefix.PrefixPublishHistoryEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("RAW(16)")
.HasColumnOrder(0)
.HasComment("คีย์หลัก");
b.Property<DateTime>("CreatedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(993)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedUserFullName")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(992)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<Guid>("CreatedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(991)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(1)
.HasComment("รายละเอียดการแก้ไข");
b.Property<DateTime?>("ModifiedDate")
.HasColumnType("TIMESTAMP(7)")
.HasColumnOrder(996)
.HasComment("แก้ไขข้อมูลเมื่อ");
b.Property<string>("ModifiedUserFullName")
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(995)
.HasComment("ชื่อ User ที่แก้ไขข้อมูล");
b.Property<Guid?>("ModifiedUserId")
.HasColumnType("RAW(16)")
.HasColumnOrder(994)
.HasComment("User Id ที่แก้ไขข้อมูล");
b.Property<string>("ObjectValue")
.IsRequired()
.HasColumnType("NVARCHAR2(2000)")
.HasColumnOrder(2)
.HasComment("เก็บ Object ที่มีการอัพเดตในระบบ");
b.HasKey("Id");
b.ToTable("MD_Prefix_Histories");
});
.HasAnnotation("Relational:MaxIdentifierLength", 64);
#pragma warning restore 612, 618
}
}

View file

@ -1,35 +1,159 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Entities.MetaData.BloodGroup;
using BMA.EHR.Domain.Entities.MetaData.Prefix;
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Infrastructure.Persistence
{
public class ApplicationDBContext : DbContext, IApplicationDBContext
{
#region " From Existing Database "
#region " Meta Data "
public DbSet<Prefix> Prefixes { get; set; }
public DbSet<BloodGroup> BloodGroups { get; set; }
public DbSet<Gender> Genders { get; set; }
public DbSet<PhysicalStatus> PhysicalStatuses { get; set; }
public DbSet<Religion> Religions { get; set; }
public DbSet<EducationLevel> EducationLevels { get; set; }
public DbSet<PositionPath> PositionPaths { get; set; }
public DbSet<PositionType> PositionTypes { get; set; }
public DbSet<PositionEmployeePosition> PositionEmployeePositions { get; set; }
public DbSet<PositionEmployeePositionSide> PositionEmployeePositionSides { get; set; }
public DbSet<PositionEmployeeGroup> PositionEmployeeGroups { get; set; }
public DbSet<PositionEmployeeLine> PositionEmployeeLines { get; set; }
public DbSet<PositionEmployeeLevel> PositionEmployeeLevels { get; set; }
public DbSet<PositionEmployeeStatus> PositionEmployeeStatuses { get; set; }
public DbSet<PositionLine> PositionLines { get; set; }
public DbSet<PositionExecutive> PositionExecutives { get; set; }
public DbSet<PositionStatus> PositionStatuss { get; set; }
public DbSet<PositionLevel> PositionLevels { get; set; }
public DbSet<Relationship> Relationships { get; set; }
public DbSet<Position> Positions { get; set; }
public DbSet<PositionPathSide> PositionPathSides { get; set; }
public DbSet<PositionExecutiveSide> PositionExecutiveSides { get; set; }
public DbSet<InsigniaType> InsigniaTypes { get; set; }
public DbSet<Insignia> Insignias { get; set; }
public DbSet<Province> Provinces { get; set; }
public DbSet<District> Districts { get; set; }
public DbSet<SubDistrict> SubDistricts { get; set; }
public DbSet<Holiday> Holidays { get; set; }
public DbSet<OrganizationType> OrganizationTypes { get; set; }
public DbSet<OrganizationLevel> OrganizationLevels { get; set; }
public DbSet<OrganizationOrganization> OrganizationOrganizations { get; set; }
public DbSet<OrganizationShortName> OrganizationShortNames { get; set; }
public DbSet<OrganizationStatus> OrganizationStatuses { get; set; }
public DbSet<OrganizationAgency> OrganizationAgencys { get; set; }
public DbSet<OrganizationGovernmentAgency> OrganizationGovernmentAgencys { get; set; }
public DbSet<OrganizationTelExternal> OrganizationTelExternals { get; set; }
public DbSet<OrganizationTelInternal> OrganizationTelInternals { get; set; }
public DbSet<OrganizationFax> OrganizationFaxs { get; set; }
public DbSet<RoyalHierarchy> RoyalHierarchys { get; set; }
public DbSet<RoyalType> RoyalTypes { get; set; }
public DbSet<Royal> Royals { get; set; }
#endregion
#endregion
public ApplicationDBContext(DbContextOptions<ApplicationDBContext> options) : base(options)
{
}
#region " Prefix "
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
public DbSet<PrefixEntity> MD_Prefixes { get; set; }
//Ignore Existing table from other service
//modelBuilder.Ignore<Prefix>();
//modelBuilder.Ignore<BloodGroup>();
//modelBuilder.Ignore<Gender>();
//modelBuilder.Ignore<PhysicalStatus>();
//modelBuilder.Ignore<Religion>();
//modelBuilder.Ignore<EducationLevel>();
//modelBuilder.Ignore<PositionPath>();
//modelBuilder.Ignore<PositionType>();
//modelBuilder.Ignore<PositionEmployeePosition>();
//modelBuilder.Ignore<PositionEmployeePositionSide>();
//modelBuilder.Ignore<PositionEmployeeGroup>();
//modelBuilder.Ignore<PositionEmployeeLine>();
//modelBuilder.Ignore<PositionEmployeeLevel>();
//modelBuilder.Ignore<PositionEmployeeStatus>();
//modelBuilder.Ignore<PositionLine>();
//modelBuilder.Ignore<PositionExecutive>();
//modelBuilder.Ignore<PositionStatus>();
//modelBuilder.Ignore<PositionLevel>();
//modelBuilder.Ignore<Relationship>();
//modelBuilder.Ignore<Position>();
//modelBuilder.Ignore<PositionPathSide>();
//modelBuilder.Ignore<PositionExecutiveSide>();
//modelBuilder.Ignore<InsigniaType>();
//modelBuilder.Ignore<Insignia>();
//modelBuilder.Ignore<Province>();
//modelBuilder.Ignore<District>();
//modelBuilder.Ignore<SubDistrict>();
//modelBuilder.Ignore<Holiday>();
//modelBuilder.Ignore<OrganizationType>();
//modelBuilder.Ignore<OrganizationLevel>();
//modelBuilder.Ignore<OrganizationOrganization>();
//modelBuilder.Ignore<OrganizationShortName>();
//modelBuilder.Ignore<OrganizationStatus>();
//modelBuilder.Ignore<OrganizationAgency>();
//modelBuilder.Ignore<OrganizationGovernmentAgency>();
//modelBuilder.Ignore<OrganizationTelExternal>();
//modelBuilder.Ignore<OrganizationTelInternal>();
//modelBuilder.Ignore<OrganizationFax>();
//modelBuilder.Ignore<RoyalHierarchy>();
//modelBuilder.Ignore<RoyalType>();
//modelBuilder.Ignore<Royal>();
public DbSet<PrefixDraftEntity> MD_Prefix_Drafts { get; set; }
base.OnModelCreating(modelBuilder);
}
public DbSet<PrefixPublishHistoryEntity> MD_Prefix_Histories { get; set; }
#endregion
#region " BloodGroups "
public DbSet<BloodGroupEntity> MD_BloodGroups { get; set; }
public DbSet<BloodGroupDraftEntity> MD_BloodGroup_Drafts { get; set; }
public DbSet<BloodGroupPublishHistoryEntity> MD_BloodGroup_Histories { get; set; }
#endregion
public override DbSet<TEntity> Set<TEntity>() where TEntity : class
{
return base.Set<TEntity>();
}
public Task<int> SaveChangesAsync()
{