测试数据库上下文
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
706cb888c8
commit
dd13eddfe3
|
@ -82,7 +82,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fluid.Core" Version="2.11.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 要生成的表名数组
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue