[성현모] [HubX] DB Scaffold 추가

This commit is contained in:
SHM
2025-03-13 09:36:55 +09:00
parent e97b5a3524
commit 25be83359b
7 changed files with 129 additions and 2 deletions

View File

@ -13,5 +13,5 @@ SET DBName=HubX
::Default DB ::Default DB
@echo off @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 CALL _CreateDB.bat %ServerIP% %ServerPort% %UserID% %Passwd% %DBName%_DEV

View File

@ -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<HubXContext> options)
: base(options)
{
}
public virtual DbSet<TStorage> 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<TStorage>(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);
}

View File

@ -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; }
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -3,10 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123 VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1 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 EndProject
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "HubX.DB", "HubX.DB\HubX.DB.sqlproj", "{514DDCCF-6B50-49F8-B212-70498396CF19}" Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "HubX.DB", "HubX.DB\HubX.DB.sqlproj", "{514DDCCF-6B50-49F8-B212-70498396CF19}"
EndProject 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 Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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.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.Build.0 = Release|Any CPU
{514DDCCF-6B50-49F8-B212-70498396CF19}.Release|Any CPU.Deploy.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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -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