您的位置:首页 > 编程语言 > ASP

asp.net core for vs code

2018-05-04 17:09 337 查看

1,命令

2,模板

3,更换启动浏览器

4,vscode使用nuget

5,使用ef migration

6,配置.net core的工作目录

7,使用dotnet ef migrations命令

8,指定migration生成的目录

9,vscode使用Bower

10,引用项目 

 

 

1,命令

 dotnet new --help 查询命令帮助

 D:\github\test2>dotnet run 启动web程序

 dotnet build 编译代码

 dotnet restore 还原包

 dotnet publish 发布项目

 

2,模板

"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "C:\\Users\\Hunter\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
"args": "${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
更新配置

 

4,vscode使用nuget

①安装nuget

② ctrl + shift +P 选择nuget,然后输入包名称回车下载

③包版本变更

打开.csproj文件,直接更改PackageReference下的Version

然后dotnet restore

 

5,使用ef migration

dotnet ef migrations add initialCreate  Add-Migration【添加更新实体】

dotnet ef database update  Update-Database【向数据库更新】

dotnet ef migrations remove  Remove-Migration【删除最后一个migration文件,前提是该migration文件为update到数据库】

dotnet ef database update LastGoodMigration Update-Database LastGoodMigration【回滚到指定的migration文件。不会删除migration文件。如果不需要migration文件可以通过dotnet ef migrations remove删除掉】

dotnet ef migrations script  Script-Migration【打印出数据库变更脚本】

 

6,配置.net core的工作目录

program:需要执行的dll cwd:被调试程序的工作目录

 

7,使用dotnet ef migrations命令

需要在工程文件中加入

 <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2"/> 和 <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2"/> 

 

8,指定migration生成的目录

 dotnet ef migrations add init -o Data/Migrations 

以后再添加不用使用  -o Data/Migrations 直接会添加在Data/Migrations文件夹下

 

9,vscode使用Bower

①vscode安装Bower扩展

 Ctrl + Shift +  p 就可以使用Bower了

②在项目中添加.bowerrc文件指定包安装路径

{
"directory": "wwwroot/lib"
}

③添加bower.json文件

{
"name": "MvcDemo2",
"private": true,
"dependencies": {
"jquery": "3.1.1",
"bootstrap": "3.3.7",
"zTree":"3.5.33"
}
}

 

10,引用项目

<ItemGroup> <ProjectReference Include="..\IdentityServer4\IdentityServer4.csproj" /> </ItemGroup>

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: