.net core EF 命令

醉酒当歌 提交于 2019-11-30 17:40:30

http://www.bsjobjob.com 璧山人才网璧山招聘网

 

https://docs.microsoft.com/zh-cn/ef/core/what-is-new/ef-core-2.0  ef 命令

https://github.com/aspnet/EntityFrameworkCore 开源地址

.net core EF 依赖库Microsoft.EntityFrameworkCore.SqlServer

                              Microsoft.EntityFrameworkCore

                              Microsoft.EntityFrameworkCore.Design

依赖库 Microsoft.EntityFrameworkCore.Tools.DotNet 节点 DotNetCliToolReference

 

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />

dotnet ef migrations add InitialCreate 迁移仓库

dotnet ef migrations list 列出所有可以迁移的仓库

dotnet ef  migrations remove 移除迁移项目

dotnet ef  migrations script 生成脚本但是不保存到文件

services.AddDbContext<EFBlogDbContext>(options=>options.UseSqlServer(Configuration.GetConnectionString("BloggingDatabase"),t=>t.MigrationsAssembly("mvc")));  注意t表达表达式 当ef和 mvc 不是一个项目时才需要t 表达式

dotnet ef migrations script -o  outpu.sql  生成数据库脚本

dotnet ef database update drop 删除数据库

dotnet ef database update update 更新数据库 建议先生成脚本

dotnet ef dbcontext info          获取 dbcontext 基本信息

dotnet ef dbcontext  list            获取所有dbcontext 基本信息

dotnet ef dbcontext scaffold             查看是否支持entity的dbcontext基本信息

 

更多细节参考 https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet

基本教程参考 https://docs.microsoft.com/en-us/ef/core/modeling/included-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!