From 25be83359b0f27419342c862e1b4f565bb4cc34d Mon Sep 17 00:00:00 2001 From: SHM Date: Thu, 13 Mar 2025 09:36:55 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=84=B1=ED=98=84=EB=AA=A8]=20[HubX]=20DB=20S?= =?UTF-8?q?caffold=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/HubX/DBPatch/CreateHubXDB.bat | 2 +- .../DB/HubX/Context/HubXContext.cs | 58 +++++++++++++++++++ .../DB/HubX/Tables/TStorage.cs | 23 ++++++++ .../HubX.Library.DB/HubX.Library.DB.csproj | 21 +++++++ .../HubX/HubX.Library/HubX.Library.csproj | 9 +++ Projects/HubX/HubX.sln | 14 ++++- Projects/HubX/Tools/Tools_DB_Scaffold.bat | 4 ++ 7 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs create mode 100644 Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs create mode 100644 Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj create mode 100644 Projects/HubX/HubX.Library/HubX.Library.csproj create mode 100644 Projects/HubX/Tools/Tools_DB_Scaffold.bat diff --git a/Projects/HubX/DBPatch/CreateHubXDB.bat b/Projects/HubX/DBPatch/CreateHubXDB.bat index 9b868a0..d30859f 100644 --- a/Projects/HubX/DBPatch/CreateHubXDB.bat +++ b/Projects/HubX/DBPatch/CreateHubXDB.bat @@ -13,5 +13,5 @@ SET DBName=HubX ::Default DB @echo off -CALL _CreateDB.bat %ServerIP% %ServerPort% %UserID% %Passwd% %DBName%_001 +CALL _CreateDB.bat %ServerIP% %ServerPort% %UserID% %Passwd% %DBName% CALL _CreateDB.bat %ServerIP% %ServerPort% %UserID% %Passwd% %DBName%_DEV \ No newline at end of file diff --git a/Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs b/Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs new file mode 100644 index 0000000..efae9f5 --- /dev/null +++ b/Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace DB.HubXDB; + +public partial class HubXContext : DbContext +{ + public HubXContext() + { + } + + public HubXContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet TStorages { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263. + => optionsBuilder.UseSqlServer("server=127.0.0.1; user id=VPKI; password=Kefico!@34; database=HubX; TrustServerCertificate=true;"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.CHuid).HasName("PK__tStorage__346C9EFC86D3DC51"); + + entity.ToTable("tStorage"); + + entity.Property(e => e.CHuid).HasColumnName("cHuid"); + entity.Property(e => e.CData1) + .HasMaxLength(4000) + .HasColumnName("cData1"); + entity.Property(e => e.CData2) + .HasMaxLength(4000) + .HasColumnName("cData2"); + entity.Property(e => e.CData3) + .HasMaxLength(4000) + .HasColumnName("cData3"); + entity.Property(e => e.CData4) + .HasMaxLength(4000) + .HasColumnName("cData4"); + entity.Property(e => e.CData5) + .HasMaxLength(4000) + .HasColumnName("cData5"); + entity.Property(e => e.CDateTime).HasColumnName("cDateTime"); + entity.Property(e => e.CIdentity) + .HasMaxLength(200) + .HasColumnName("cIdentity"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs b/Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs new file mode 100644 index 0000000..2b90c0c --- /dev/null +++ b/Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace DB.HubXDB; + +public partial class TStorage +{ + public long CHuid { get; set; } + + public string CIdentity { get; set; } = null!; + + public DateTime CDateTime { get; set; } + + public string? CData1 { get; set; } + + public string? CData2 { get; set; } + + public string? CData3 { get; set; } + + public string? CData4 { get; set; } + + public string? CData5 { get; set; } +} diff --git a/Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj b/Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj new file mode 100644 index 0000000..7ff51e6 --- /dev/null +++ b/Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj @@ -0,0 +1,21 @@ + + + + net8.0 + enable + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Projects/HubX/HubX.Library/HubX.Library.csproj b/Projects/HubX/HubX.Library/HubX.Library.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/Projects/HubX/HubX.Library/HubX.Library.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/Projects/HubX/HubX.sln b/Projects/HubX/HubX.sln index fc23744..555a145 100644 --- a/Projects/HubX/HubX.sln +++ b/Projects/HubX/HubX.sln @@ -3,10 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HubX.Server", "HubX.Server\HubX.Server.csproj", "{AFAF8DB4-790C-4482-9B31-3DFFE4FF3DB7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HubX.Server", "HubX.Server\HubX.Server.csproj", "{AFAF8DB4-790C-4482-9B31-3DFFE4FF3DB7}" EndProject Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "HubX.DB", "HubX.DB\HubX.DB.sqlproj", "{514DDCCF-6B50-49F8-B212-70498396CF19}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HubX.Library", "HubX.Library\HubX.Library.csproj", "{E6FA1D27-A644-4E50-BF16-DCCA59AA378D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HubX.Library.DB", "HubX.Library.DB\HubX.Library.DB.csproj", "{C43CF1F1-9CB0-44DC-89D7-3514F18EAD46}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,6 +27,14 @@ Global {514DDCCF-6B50-49F8-B212-70498396CF19}.Release|Any CPU.ActiveCfg = Release|Any CPU {514DDCCF-6B50-49F8-B212-70498396CF19}.Release|Any CPU.Build.0 = Release|Any CPU {514DDCCF-6B50-49F8-B212-70498396CF19}.Release|Any CPU.Deploy.0 = Release|Any CPU + {E6FA1D27-A644-4E50-BF16-DCCA59AA378D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6FA1D27-A644-4E50-BF16-DCCA59AA378D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6FA1D27-A644-4E50-BF16-DCCA59AA378D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6FA1D27-A644-4E50-BF16-DCCA59AA378D}.Release|Any CPU.Build.0 = Release|Any CPU + {C43CF1F1-9CB0-44DC-89D7-3514F18EAD46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C43CF1F1-9CB0-44DC-89D7-3514F18EAD46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C43CF1F1-9CB0-44DC-89D7-3514F18EAD46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C43CF1F1-9CB0-44DC-89D7-3514F18EAD46}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Projects/HubX/Tools/Tools_DB_Scaffold.bat b/Projects/HubX/Tools/Tools_DB_Scaffold.bat new file mode 100644 index 0000000..582be5f --- /dev/null +++ b/Projects/HubX/Tools/Tools_DB_Scaffold.bat @@ -0,0 +1,4 @@ +cd ../HubX.Library.DB + +::DataDB +dotnet ef dbcontext scaffold "server=127.0.0.1; user id=VPKI; password=Kefico!@34; database=HubX; TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer --namespace DB.HubXDB --context-dir DB\HubX\Context --output-dir DB\HubX\Tables -f \ No newline at end of file