一、.NetCore EF 之命令行
一、前言
最近在学习研究ABP,使用到微软的ORM框架 Entity Framework(后面简称EF),将其基本操作记录下来。
二、程序包管理器控制台
为了能够在控制台中使用命令行来操作EF,需要先安装Microsoft.EntityFrameworkCore.Tools。
安装
Install-Package Microsoft.EntityFrameworkCore.Tools
更新
通过该指令就可以升级Microsoft.EntityFrameworkCore.Tools
Update-Package Microsoft.EntityFrameworkCore.Tools
查看
通过该指令就可以查看Microsoft.EntityFrameworkCore.Tools
Get-Help about_EntityFrameworkCore
三、命令行指令
Add-Migration Adds a new migration.
Drop-Database Drops the database.
Get-DbContext Gets information about a DbContext type.
Remove-Migration Removes the last migration.
Scaffold-DbContext Scaffolds a DbContext and entity types for a database.
Script-Migration Generates a SQL script from migrations.
Update-Database Updates the database to a specified migration.
四、CodeFirst 命令步骤
添加EntityFramework
命令:Install-Package EntityFramework
1、启用迁移
Enable-Migrations
2、为挂起的Model变化添加迁移脚本
Add-Migration 名字 (在已有数据库中使用Code First时标记当前数据库状态: Add-Migration 名字 -IgnoreChanges)
3、将挂起的迁移更新到数据库
Update-Database
一、.NetCore EF 之命令行的更多相关文章
- EF常用命令行
启用迁移:指定迁移的目录和数据库上下文名称Enable-Migrations -MigrationsDirectory "MigrationsHis" -ContextTypeNa ...
- 《Entity Framework 6 Recipes》中文翻译系列 (40) ------ 第七章 使用对象服务之从跟踪器中获取实体与从命令行生成模型(想解决EF第一次查询慢的,请阅读)
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 7-5 从跟踪器中获取实体 问题 你想创建一个扩展方法,从跟踪器中获取实体,用于数 ...
- 在VS Nuget命令行下进行EF数据库迁移
找到项目中,用到数据库DLL的地方,然后选中该项目,打开Nuget命令行输入以下的命令: 其中cardId为迁移名称,自己取
- netcore命令行部署|跨域问题
1.在hosting中修改发布端口号,如遇见不识别IP则改成*再用命令行运行 { "server.url": "http://*:8089"} 3.给接口开外网 ...
- 使用.NET Core快速开发一个较正规的命令行应用程序
程序员的世界,命令行工具一直是"体验非常友好"的工具,也能自动化完成很多事情,同时还能结合shell来进行某项任务的批处理(脚本).在.NET Core中,命令行应用程序是基础,但 ...
- .NET Core系列 : 1、.NET Core 环境搭建和命令行CLI入门
2016年6月27日.NET Core & ASP.NET Core 1.0在Redhat峰会上正式发布,社区里涌现了很多文章,我也计划写个系列文章,原因是.NET Core的入门门槛相当高, ...
- Linux命令行上程序执行的那一刹那!
转自:http://www.cppblog.com/cuijixin/archive/2008/03/14/44463.html by falcon<zhangjinw@gmail.com> ...
- JMeter学习-024-JMeter 命令行(非GUI)模式详解(二)-执行代理设置
闲话少述,接 上文 继续... 5.设置代理 jmeter -n -t JMeter分布式测试示例.jmx -H 20.9.215.90 -P 9999 -l report\01-result.csv ...
- 在 Mac OS X 上创建的 .NET 命令行程序访问数据库 (使用Entity Framework 7 )
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
随机推荐
- 网上搜集python面试题(更新中......)
武Sir博客拿的面试题,答案都是自己写的,多有不足,请多多指教.更新中...... 1.为什么学习Python? a.写起来快,看起来明白.作为通用性的语言,除了一些对性能要求很高的场合,几乎什么都能 ...
- hashlib,hmac,subprocess,configparser,xlrd,xlwt,xml模块基本功能
hashlib模块:加密 import hashlib# 基本使用cipher = hashlib.md5('需要加密的数据的二进制形式'.encode('utf-8'))print(cipher.h ...
- 注意C语言 / 要想得到精确结果
#include <stdio.h> int main(){ double r; while(scanf("%lf",&r)!=EOF) { ...
- JS拖拽div(移动)
<!doctype html><html><head> <meta charset="utf-8"> <title>JS ...
- JavaScript作用域(第七天)
我们都知道js代码是由自上而下的执行,但我们来看看下面的代码: test(); function test(){ console.log("hello world"); }; 如果 ...
- SP3871 GCDEX - GCD Extreme
//author Eterna #define Hello the_cruel_world! #pragma GCC optimize(2) #include<iostream> #inc ...
- cordova原生页面切换效果插件的使用:com.telerik.plugins.nativepagetransitions
1. 添加插件:cordova plugin add com.telerik.plugins.nativepagetransitions2. 使用方法: 在index.html中添加: <met ...
- test png
$x^2 \int $ When $a \ne 0$, there are two solutions to (ax^2 + bx + c = 0) and they are $$x = {-b \p ...
- securecrt-active
Mac下面的SecureCRT(附破解方案) 更新到最新的7.3.7 转自 http://bbs.weiphone.com/read-htm-tid-6939481.html 继续更新到7.3.2的破 ...
- python查询mysql并生成excel表
需求说明 开发不愿意单独为某个项目做后台 并且运营那边需要合并多个表的数据 因此找上了我. 要求每周执行一次.月初也执行一次 要查询2个mysql数据库多个表并生成excel表 我的想法 找开发要sq ...