# NetCoreT4 **Repository Path**: wangjiec/net-core-t4 ## Basic Information - **Project Name**: NetCoreT4 - **Description**: 我的个人,Net模板项目,使用T4 Template 自动生成Repository、Service代码 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-08-02 - **Last Updated**: 2024-08-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # T4 Project Doc 🇨 🇳 - [T4 Project Doc](#t4-project-doc) - [项目实现功能](#项目实现功能) - [使用介绍](#使用介绍) ## 项目实现功能 - [x] 采用 `仓储 + 服务 + 接口` 的形式封装 - [x] 使用 [T4 模板](https://docs.microsoft.com/zh-cn/visualstudio/modeling/code-generation-and-t4-text-templates?view=vs-2022)(`Text Template Transformation Toolkit`)生成实体对应的数据库配置、仓储、服务 - [x] 使用 NLog 记录日志 - [x] 支持多数据库`MySql`、`SqlServer` - [x] 使用 `Swagger` - [ ] 使用 `Radis` 缓存数据 - [ ] 使用 `AOP` 切面 - [ ] 日志缓存 ## 使用介绍 > ### T4 模板文件使用 > > 设计思路: 读取`Domain`项目中`Models`文件夹下的文件,使用其文件名作为 T4 模板生成文件的依据。 生成文件: - 数据库的配置文件(`Domain\Configurations\[ModelName]Configuration`) - 仓储文件`IRepositories`项目下(`I[ModelName]Repository`) & `Repositories`项目下(`[ModelName]Repository`) - `IUnitOfWork`文件和`UnitOfWork`文件 - 服务文件`IServices`项目下(`I[ModelName]Service`) & `Services`项目下(`[ModelName]Service`) > #### 新增一个实体 1. 在`Domain`项目中`Models`文件夹下新增一个模型文件(`[NewModel]`.cs); 2. 依次点击 Framework 项目下的文件 1. EntityAuto\EntityConfiguration.tt 1. 生成`Domain\Configurations\[NewModel]Configuration.cs`; 2. 在`Domain\Context\EntityContainer.cs`添加 DbSet; 2. IRepository\IRepository.tt 1. 生成`IRepositories\[NewModel]\I[NewModel]Repository.cs`; 3. Repository\Repository.tt 1. 生成`Repositories\[NewModel]\[NewModel]Repository.cs`; 4. IService\IService.tt 1. 生成`IServices\[NewModel]\I[NewModel]Service.cs`; 5. Service\Service.tt 1. 生成`Services\[NewModel]\[NewModel]Service.cs`; ##