首页 > 其他分享 >.Net6 and VsCode CodeFirst开发和迁移使用

.Net6 and VsCode CodeFirst开发和迁移使用

时间:2023-11-09 23:55:34浏览次数:34  
标签:CodeFirst global VsCode IntelliCode ef -- dotnet Net6 C#

------------VsCode开发.net6----------------------------------
干货如下:
C# Base language support for C# 包含vscode的调试 C# Dev Kit C# Extensions IntelliCode IntelliCode API Usage Examples IntelliCode Completions IntelliCode for C# Dev Kit IntelliCode Insiders NuGet Package Manager GUI vscode-solution-explorer Auto-Using for C# vscode调试时 其他端口需要关闭不占用,点击vscode左侧的虫子按钮即可-运行和调试

调式运行前会自动打开Swagger,截图省略

Vscode CodeFirst 迁移,使用PgSql,code中下面4个nuget包

  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />


    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13" />

  </ItemGroup>

迁移使用到的命令

===========CodeFirst 如下两种方式命令
0:使用命令行工具
dotnet ef migrations add Init   --注意这里是多一个migrationss
dotnet ef database update

1:使用程序包管理器控制台
Add-Migration Init
Update-Database


无法将“dotnet-ef”项识别为 cmdlet、函数、脚本文件或可运行程序的名称,解决方案如下:

Net6的dotnet-ef工具环境:
dotnet tool install --global dotnet-ef --version 7.0.13

.NetCore3的dotnet-ef工具环境:
dotnet tool install --global dotnet-ef --version 3.1.0


=========vscode迁移钥使用到的小插件工具

dotnet ef cli全局安装
dotnet tool install --global dotnet-ef

更新EFCore CLI
dotnet tool update --global dotnet-ef

卸载EFCore CLI
dotnet tool uninstall --global dotnet-ef

验证EFCORE CLI
dotnet ef

 

标签:CodeFirst,global,VsCode,IntelliCode,ef,--,dotnet,Net6,C#
From: https://www.cnblogs.com/Fengge518/p/17803613.html

相关文章

  • python升级到3.12版本, 开发模式安装包, 在vscode下Pylance无法解析的问题处理
    问题描述在python3.11版本下开发python库,为方便调测,使用开发模式安装包.使用如下命令:pipinstall-e.其中-e参数表示开发模式下安装python包,它并没有把包相关文件拷贝到site-packages目录,而是创建一个链接指向当前的开发库.这样,当自己开发的包修改后会立即生效,......
  • C# EntityFramework+SQLite CodeFirst 创建数据库和数据表
    1、安装NuGet包System.Data.SQLite(System.Data.SQLite.Core、System.Data.SQLite.EF6、System.Data.SQLite.Linq)SQLite.CodeFirstEntityFramework2、配置App.config<?xmlversion="1.0"encoding="utf-8"?><configuration><configSe......
  • 使用 VSCode+CMake+Ninja 开发RISC-V MCU
    1.安装软件及工具1.1VSCode安装VisualStudionCode(VSCode),是一款由微软开发且跨平台的免费源代码编辑器。该软件支持语法高亮、代码自动补全(又称IntelliSense)、代码重构、查看定义功能,并且内置了命令行工具和Git版本控制系统。VSCode官网VSCode官方文档官网......
  • VSCode软件使用
    2023-06-25   https://www.cnblogs.com/NJ-Leon/ 一、插件名称说明参考C/C++c/c++语言 OneDarkPro主题 highlight-words高亮https://zhuanlan.zhihu.com/p/113017073BracketPairColorizer2括号 Book......
  • 搭建 Makefile+OpenOCD+CMSIS-DAP+Vscode arm-none-eabi-gcc 工程模板
    STM32F407-GCC-TemplateArm-none-eabi-gcc+Makefile+OpenOCD+CMSIS-DAP+Vscode工程模板一、本次环境搭建所用的软硬件1)WindowsorLinux(本文以Windows为主)2)JLink、Daplink、Wch-Link烧录器3)GNUArmEmbeddedToolchain交叉编译器4)Mingw-w64GCCforWindows645)Debug......
  • yarn在vscode运行报错怎么解决
    修改powerShell策略,需要修改权限(电脑脚本不信任,所以阻止了脚本的运行) 输入set-ExcutionPolicyRemoteSigned更改策略,选择A全是,执行更改然后再使用yarn–version验证版本   使用yarnserve在vscode中验证项目是否能正常执行......
  • Windows10+VSCode+CMake+shell脚本编译C/C++程序
    一、概述想要在Windows10上做C++验证/编译类库,借助VSCode(其实这东西要不要都行,它就是来方便查看代码的)+CMake+shell脚本做程序的编译运行。下面写一个小例子记录一下准备工作:1.编译环境用的是mingw64,使用其再带的g++编译,ps:记得要配置其环境变量2......
  • Asp.Net Core webapi+net6 使用资源筛选器(过滤器) 做缓存
    写一个特性类,用来做标记[AttributeUsage(AttributeTargets.Method)]//只对方法有效publicclassResourceFilterAttribute:Attribute{}我这里使用了MemoryCache来做缓存,也可以使用字典来做,但一定要加上static,否则字典每一次请求都会new一个实例,缓存的东西就丢了private......
  • vscode快捷输入vue2,vue3,模板
    { //Placeyoursnippetsforvuehere.Eachsnippetisdefinedunderasnippetnameandhasaprefix,bodyand //description.Theprefixiswhatisusedtotriggerthesnippetandthebodywillbeexpandedandinserted.Possiblevariablesare: //$1,......
  • Vscode 安装pyside6
    1.在VScode扩展中安装pyqtintegration2.pyqtintegration设置pyrcc;pyuic;Qtdesigner的路径 ......