visual studio 2019 for mac开发asp.net(abp) 使用手册及注意事项
2020-07-20 04:07
1886 查看
官方使用手册
自动保存整理代码
首选项 ->文本编辑器 ->行为
在解决方案中搜索
shift+command+F
程序包管理器控制平台
Visual Studio for Mac 或 Visual Studio Code 中未提供该控制台。参考->
🉑️通过mac自带的终端进行操作.
当操作的时候发现dotnet ef命令并不被支持。
Could not execute because the specified command or file was not found.
需要安装工具,参考->
dotnet tool install --global dotnet-ef # 可卸载 dotnet tool uninstall --global dotnet-ef dotnet tool list -g # 设置环境变量 export PATH="$PATH:$HOME/.dotnet/tools/" # dotnet ef OK dotnet ef _/\__ ---==/ \\ ___ ___ |. \|\ | __|| __| | ) \\\ | _| | _| \_/ | //|\\ |___||_| / \\\/\\
安装成功之后,可操作EntityFrameworkCore
# EntityFrameworkCore项目路径 cd xxx.EntityFrameworkCore # = add-migration "update OU" dotnet ef migrations add "update OU" # = 多个Context时需指定 dotnet ef migrations add initail -c XXDbContext dotnet ef migrations list dotnet ef migrations remove # = update-database dotnet ef database update dotnet ef database update -c # = install-package dotnet add package -h|--help
database update 之后将生成db文件,种子数据在运行时生成。
注意⚠️:
因为我配置的是sqlite数据库,连接的数据库路径为相对路径。
{ "ConnectionStrings": { "Default": "Server=localhost; Database=AprilDb; Trusted_Connection=True;", "SqliteCnn": "Data Source=AprilDb.db;" },
当解决方案是由多个程序集组成时,会有路径冲突问题。
我的程序集名称如下:
April.Application April.Core # migrations April.EntityFrameworkCore April.Migrator April.Web.Core # configure database string April.Web.Host
在windows下,只在April.Web.Host生成一个db文件。而在mac下,同样的配置,database update时在April.EntityFrameworkCore生成一个文件,而运行时候(种子数据写入)在April.Web.Host生成一个空db文件。
所以修改连接路径如下:
{ "ConnectionStrings": { "Default": "Server=localhost; Database=AprilDb; Trusted_Connection=True;", "SqliteCnn": "Data Source=../April.EntityFrameworkCore/AprilDb.db;" },
abp中nswag的使用
refresh.bat只能在windows下生成代理文件,但是refresh.bat内的内容可在mac下运行。
cd nswag ../node_modules/.bin/nswag run # or ./node_modules/.bin/nswag run ./nswag/service.config.nswag
或者在package.json中添加执行命令
"nswag": "./node_modules/.bin/nswag run nswag/service.config.nswag"
cd ./node_modules/.bin/nswag默认的netcore版本是2.1,可以将版本号改为高版本后后再运行
#!/usr/bin/env node "use strict"; var defaultCoreVersion = "31";
运行npm run nswag。
> ng-alain@8.9.2 nswag /Users/xxx/projects/DotNet/April/alain > nswag run nswag/service.config.nswag NSwag NPM CLI NSwag command line tool for .NET Core NetCore31, toolchain v13.6.1.0 (NJsonSchema v10.1.21.0 (Newtonsoft.Json v12.0.0.0)) Visit http://NSwag.org for more information. NSwag bin directory: /Users/xxx/projects/DotNet/April/alain/node_modules/nswag/bin/binaries/NetCore31 Executing file 'nswag/service.config.nswag' with variables ''... Done. Duration: 00:00:02.0827282
相关文章推荐
- 64位系统使用VS2010开发32位ASP.NET应用--注意事项
- 项目开发中的一些注意事项以及技巧总结 基于Repository模式设计项目架构—你可以参考的项目架构设计 Asp.Net Core中使用RSA加密 EF Core中的多对多映射如何实现? asp.net core下的如何给网站做安全设置 获取服务端https证书 Js异常捕获
- Asp.net &C#开发中的一些注意事项及小技巧
- 如何不使用 Visual Studio 开发ASP.NET
- AspDotNetStorefront中事件处理页面开发的注意事项
- asp.net mvc 中对easyui的引用文件使用Bundle的注意事项
- ASP.NET Oracle数据库使用事务时注意事项
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
- 使用Visual Studio 2015 开发ASP.NET MVC 5 项目部署到Mono/Jexus
- ASP.NET AJAX里使用Update Panel需要注意的事项
- 在ASP.NET中使用MySQLMembershipProvider注意事项
- 使用ASP.NET制作Wap网站注意事项
- asp.net开发注意事项
- ASP.NET MVC 使用MSBuild生成的几个注意事项
- ASP.NET MVC+EF在服务端分页使用jqGrid以及jquery Datatables的注意事项
- ASP.NET控件GridView的使用& Xml操作注意事项
- 使用ASP.NET AJAX的注意事项
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
- 使用ASP.NET AJAX的注意事项
- 『飞秋』在ASP.NET服务器端过程中使用WebBrowser的注意事项