From dd13eddfe3bc22e43c1c5e82b7ac7d647f5205e1 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Thu, 5 Sep 2024 00:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 2 ++ IRaCIS.Core.Test/Program.cs | 22 ++++++++++++++++++++++ IRaCIS.Core.Test/Template/YourDbContext.cs | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 IRaCIS.Core.Test/Template/YourDbContext.cs diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index fc8d2d1ec..b00d3c836 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -82,7 +82,9 @@ + + diff --git a/IRaCIS.Core.Test/Program.cs b/IRaCIS.Core.Test/Program.cs index 5c692dbac..0481b1089 100644 --- a/IRaCIS.Core.Test/Program.cs +++ b/IRaCIS.Core.Test/Program.cs @@ -1,5 +1,8 @@  using Fluid; +using IRaCIS.Core.Test.Template; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; @@ -42,6 +45,25 @@ partial class Program Directory.CreateDirectory(dtoPath); } #endregion + using (var context = new YourDbContext()) + { + var model = context.Model; + + foreach (var entityType in model.GetEntityTypes()) + { + string tableName = entityType.GetTableName(); + Console.WriteLine($"Table: {tableName}"); + + foreach (var property in entityType.GetProperties()) + { + string columnName = property.GetColumnName(); + string dataType = property.ClrType.Name; + bool isNullable = property.IsNullable; + + Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}"); + } + } + } // 要生成的表名数组 diff --git a/IRaCIS.Core.Test/Template/YourDbContext.cs b/IRaCIS.Core.Test/Template/YourDbContext.cs new file mode 100644 index 000000000..09593fc25 --- /dev/null +++ b/IRaCIS.Core.Test/Template/YourDbContext.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Test.Template +{ + class YourDbContext : DbContext + { + + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true"); + } + + } +}