This commit is contained in:
橙子
2021-10-17 18:38:58 +08:00
23 changed files with 343 additions and 18 deletions

View File

@@ -10,5 +10,6 @@ namespace Yi.Framework.Model.Models
{
public int? is_top { get; set; }
public int? sort { get; set; }
public int? is_show { get; set; }
}
}

View File

@@ -34,7 +34,6 @@ namespace Yi.Framework.Model
optionsBuilder.UseSqlite(_connStr);
}
}
public DbSet<user> user { get; set; }
public DbSet<role> role { get; set; }
}
}

View File

@@ -11,7 +11,7 @@ namespace Yi.Framework.Model.Models
public string icon { get; set; }
public string router { get; set; }
public string menu_name { get; set; }
public ICollection<menu> children { get; set; }

View File

@@ -0,0 +1,17 @@
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
{
public DbSet<menu> menu { get; set; }
public DbSet<mould> mould { get; set; }
public DbSet<role> role { get; set; }
public DbSet<user> user { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
<#@ 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" #>
<#
DirectoryInfo dir = new DirectoryInfo(@"D:\YiFramework\Yi\Yi.Framework\Yi.Framework.Model\Models\");
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; }
<# } #>
}
}

View File

@@ -8,6 +8,14 @@
<Folder Include="Search\" />
</ItemGroup>
<ItemGroup>
<None Include="T4DataContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>T4DataContext.tt</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
@@ -28,6 +36,10 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>T4DaraContext.cs</LastGenOutput>
</None>
<None Update="T4DataContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>T4DataContext.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
@@ -40,6 +52,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>T4DaraContext.tt</DependentUpon>
</Compile>
<Compile Update="T4DataContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>T4DataContext.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>