[성현모] [HubX] DB Scaffold 추가
This commit is contained in:
@ -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
|
||||
58
Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs
Normal file
58
Projects/HubX/HubX.Library.DB/DB/HubX/Context/HubXContext.cs
Normal 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);
|
||||
}
|
||||
23
Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs
Normal file
23
Projects/HubX/HubX.Library.DB/DB/HubX/Tables/TStorage.cs
Normal 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; }
|
||||
}
|
||||
21
Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj
Normal file
21
Projects/HubX/HubX.Library.DB/HubX.Library.DB.csproj
Normal 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>
|
||||
9
Projects/HubX/HubX.Library/HubX.Library.csproj
Normal file
9
Projects/HubX/HubX.Library/HubX.Library.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -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
|
||||
|
||||
4
Projects/HubX/Tools/Tools_DB_Scaffold.bat
Normal file
4
Projects/HubX/Tools/Tools_DB_Scaffold.bat
Normal 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
|
||||
Reference in New Issue
Block a user