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
来源:oschina
链接:https://my.oschina.net/u/120845/blog/1069010