-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Framework
ansonzhang edited this page Oct 15, 2019
·
1 revision
项目开发后期,如果添加了一个表,但是需要生成四个层文件,比较麻烦,我根据SQL sugar相关内容,写了一个自动生成的方法。
注意:相关代码是 netcore 3.0分支的
Blog.Core.Model/Seed/MyContext.cs
Blog.Core.Model/Seed/FrameSeed.cs(可自定义文件生成路径)
services.AddScoped<Blog.Core.Model.Models.MyContext>();
Blog.Core/Controller/DbFirst/DbFirstController.cs
private readonly MyContext myContext;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="myContext"></param>
public DbFirstController(MyContext myContext)
{
this.myContext = myContext;
}
/// <summary>
/// 获取 整体框架 文件
/// </summary>
/// <returns></returns>
[HttpGet]
public bool GetFrameFiles()
{
return FrameSeed.CreateModels(myContext)
&& FrameSeed.CreateIRepositorys(myContext)
&& FrameSeed.CreateIServices(myContext)
&& FrameSeed.CreateRepository(myContext)
&& FrameSeed.CreateServices(myContext)
;
}
有疑问,请自行查看博客园文章:https://www.cnblogs.com/laozhang-is-phi/p/9495618.html#autoid-1-0-0
或者加 QQ 群:867095512
-
- AOP
- Appsettings
- Async-Await
- Authorization-Ids4
- Authorization-JWT
- AutoMapper
- CORS
- DI-AutoFac
- DI-NetCore
- Filter
- GlobalExceptionsFilter
- HttpContext
- Log4
- MemoryCache
- Middleware
- MiniProfiler
- publish
- Redis
- Repository
- SeedData
- SignalR
- SqlSugar
- SqlSugar-Codefirst&DataSeed
- SqlSugar-SqlAOP
- Swagger
- T4
- Test-xUnit
- Temple-Nuget
- FAQ page is a good place to see whether your question is already asked.
- Ask a question in cnblogs if you need help.
- Submit an issue if you found a bug or have a feature request.
- Open a pull request when you prepared to contribute. Before that, it is encouraged to open an issue to discuss.