https://github.com/systemlight/t-sharpgun
:lock: :package: More comprehensive `.Net5` web development template【更加全面的.Net5 Web开发模板】
https://github.com/systemlight/t-sharpgun
csharp dotnet5 mvc templates web
Last synced: 5 months ago
JSON representation
:lock: :package: More comprehensive `.Net5` web development template【更加全面的.Net5 Web开发模板】
- Host: GitHub
- URL: https://github.com/systemlight/t-sharpgun
- Owner: SystemLight
- License: mit
- Created: 2020-08-03T15:42:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T20:11:19.000Z (almost 2 years ago)
- Last Synced: 2025-03-03T03:12:55.433Z (10 months ago)
- Topics: csharp, dotnet5, mvc, templates, web
- Language: C#
- Homepage:
- Size: 288 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SharpGun
更加全面的.Net5 Web开发模板
## 技术栈
#### 核心环境
- [x] .Net5 (Sdk=Microsoft.NET.Sdk.Web)
#### 依赖包
- [X] Microsoft.AspNetCore.SpaServices.Extensions
- [X] Microsoft.AspNetCore.Mvc.NewtonsoftJson
- [X] Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
- [X] Microsoft.AspNet.WebApi.Versioning
- [X] Microsoft.AspNet.WebApi.Versioning.ApiExplorer
- [X] Microsoft.EntityFrameworkCore
- [X] Microsoft.EntityFrameworkCore.tools
- [X] Microsoft.EntityFrameworkCore.SqlServer
- [X] Microsoft.Extensions.Logging.Log4Net.AspNetCore
- [X] Autofac.Extensions.DependencyInjection
- [X] Autofac.Extras.DynamicProxy
- [X] Castle.Core
- [X] Swashbuckle.AspNetCore
- [X] System.Data.SqlClient
## 目录结构
| 文件名 | 作用 |
| :---- | :---- |
| Controllers | 网络请求捕获控制 |
| Converts | 转换映射处理 |
| Extensions | 拓展原有方法,中间件等 |
| Misc | 转换器,过滤器,异常处理,规则配置类,实用工具等 |
| Models | 数据或业务模型 |
| Pages | 独立Razor页面 |
| Services | 服务类存放处 |
| ViewModels | 视图模型映射类 |
| Views | MVC视图访问文件夹 |
| wwwroot | 默认静态文件访问路径 |
| Program.cs | 核心程序入口文件 |
| Startup.cs | 中间件注入,app启动配置文件 |
## 注释规范
1. 代码块注释
```c#
#region 代码块说明
/*
代码块内容
*/
#endregion
```
2. 功能解释注释
```c#
/*
解释说明内容:
*/
```
3. 单行逻辑注释
```c#
// 功能说明
app.UseRouting();
```
## 模型生成
#### 安装工具
```
dotnet tool install --global dotnet-ef
```
#### 添加依赖包(SqlServer)
```
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.tools
Microsoft.EntityFrameworkCore.SqlServer
```
#### 数据库映射对象(SqlServer)
- [更多指令参考](https://docs.microsoft.com/zh-cn/ef/core/cli/dotnet)
```
dotnet ef dbcontext scaffold "Data Source=[数据库地址];Initial Catalog=[数据库名];User ID=[用户名];Password=[密码]" Microsoft.EntityFrameworkCore.SqlServer -o Entity -f -c MyDbContext --context-dir ./
```
## 应用部署
#### Kestrel
```
dotnet publish
cd bin/Debug/net5.0/publish && .exe
或
cd bin/Debug/net5.0/publish && dotnent .dll --urls="http://*:5000" --ip="127.0.0.1" --port=5000
```
#### IIS
```
dotnet publish -c Release
cd bin/Debug/net5.0/publish
```