提交.Net6版本
This commit is contained in:
40
Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.tt
Normal file
40
Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.tt
Normal file
@@ -0,0 +1,40 @@
|
||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#
|
||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
||||
string dirPath= Path.Combine(solutionsPath,@"Yi.Framework.Model\Models\");
|
||||
DirectoryInfo dir = new DirectoryInfo(dirPath);
|
||||
FileInfo[] finfo = dir.GetFiles();
|
||||
string filenames = string.Empty;
|
||||
List<string> filenameList = new List<string>();
|
||||
for (int i = 0; i < finfo.Length; i++)
|
||||
{
|
||||
filenames = finfo[i].Name ;
|
||||
string[] f=filenames.Split('.');
|
||||
filenameList.Add(f[0]);
|
||||
}
|
||||
|
||||
|
||||
#>
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.Model
|
||||
{
|
||||
public partial class DataContext :DbContext
|
||||
{
|
||||
<# foreach(string k in filenameList){
|
||||
#>
|
||||
public DbSet<<#=k #>> <#=k #> { get; set; }
|
||||
<# } #>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user