efcore 控制台迁移架构
添加 nuget 包:
- Microsoft.EntityFrameworkCore.Design
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Tools
继承接口:
IDesignTimeDbContextFactory<XXDbContext>
实现接口:
public XXDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<XXDbContext >()
.UseSqlServer(_dbConnectionString, builder =>
builder.MigrationsAssembly(typeof(Program).Namespace)); return new XXDbContext (optionsBuilder.Options);
}
efcore-cli (command bat 放在了 "ef-cli" 文件夹下面):
migrations :
cd ..
rmdir /S /Q Migrations dotnet ef migrations add InitialXXDbContextMigration -c XXDbContext -o Migrations/XXDb dotnet ef migrations script -c XXDbContext -o Migrations/XXDb.sql cd ef-cli
update db:
cd ..
dotnet ef database update -c XXDbContext
cd ef-cli
drop db:
cd ..
dotnet ef database drop -c XXDbContext
cd ef-cli
efcore 控制台迁移架构的更多相关文章
- EFCore数据库迁移命令整理
前言 因为现在用.net core 开发新项目,过程中需要经常涉及到数据命令的迁移,今天分别整EFCore 的两种迁移数据库的方式 1 程序包管理器控制台 , Package Manager Con ...
- Entity Framework Code First 多数据库 控制台迁移代码
1.启动迁移 Enable Migrations Enable-Migrations -MigrationsDirectory "MigrationsOne" -ContextTy ...
- EFCore自动迁移
2019/05/14,EFCore 2.2.4 有两种方式: 使用Migrate()方法 if (DbContext.Database.GetPendingMigrations().Any()) { ...
- .net core EFCore CodeFirst 迁移出现错误【No project was found. Change the current working directory or use the --project option. 】
PM> dotnet ef Migrations add Init No project was found. Change the current working directory or u ...
- ASP.NET Core搭建多层网站架构【5-网站数据库实体设计及映射配置】
2020/01/29, ASP.NET Core 3.1, VS2019, EntityFrameworkCore 3.1.1, Microsoft.Extensions.Logging.Consol ...
- EntityFrameworkCore数据迁移(一)
.net core出来已经有很长一段时间了,而EentityFrameworkCore(后面简称EFCore)是.net framework的EntityFramework在.net core中的实现 ...
- Windows Server 2016-图形化迁移FSMO角色
上章节我们简单介绍了三种不同方式查看FSMO主机角色信息,在开篇之前我们简单回顾一下FSMO五种操作主机角色:林范围操作主机角色有两种,分别是 架构主机角色(Schema Master)和 域命名主机 ...
- efcore分表分库原理解析
ShardingCore ShardingCore 易用.简单.高性能.普适性,是一款扩展针对efcore生态下的分表分库的扩展解决方案,支持efcore2+的所有版本,支持efcore2+的所有数据 ...
- 不同场景下 MySQL 的迁移方案
一 目录 一 目录 二 为什么要迁移 三 MySQL 迁移方案概览 四 MySQL 迁移实战 4.1 场景一 一主一从结构迁移从库 4.2 场景二 一主一从结构迁移指定库 4.3 场景三 一主一从结构 ...
随机推荐
- (40). springboot + devtools(热部署)【从零开始学Spring Boot】
我们之前在在()Spring Boot热部署[从零开始学Spring Boot] (http://412887952-qq-com.iteye.com/blog/2291518 )讲过通过使用spri ...
- libcloud代码研究(三)——bugs
Bug 1:对不可迭代类进行迭代(libcloud.storage.driver.cloudfile line. 141-142) 使用libcloud连接自搭建swift服务,自己在服务器 ...
- MySql 格式化时间(包括正常时间格式与unix时间戳的互相转换)
函数:FROM_UNIXTIME 作用:将MYSQL中以INT(11)存储的时间以"YYYY-MM-DD"格式来显示.语法:FROM_UNIXTIME(unix_timestamp ...
- Servlet中使用getInputStream进行文件上传
据说古老了点,所以代码比较繁琐,主要用于处理文件的地方太多. 下节用SERVLET3.0的Part进行操作一下. form.html: <!DOCTYPE html> <html&g ...
- [bzoj3524/2223][Poi2014]Couriers_主席树
Couriers bzoj-3524 Poi-2014 题目大意:给定n个数的序列,询问区间内是否存在一个在区间内至少出现了(区间长度>>1)次的数.如果有,输出该数,反之输出0. 注释: ...
- N天学习一个linux命令之rsync
用途 主要用于本地和远程主机同步文件 特性 1 使用增量传输算法(delta-transfer algorithm) 2 支持ssh,rsync协议 3 可以用于本地同步文件 4 本地和远程主机都需要 ...
- C语言函数--H
函数名: harderr 功 能: 建立一个硬件错误处理程序 用 法: void harderr(int (*fptr)()); 程序例: /*This program will trap disk ...
- 杂项-Java:标签库
ylbtech-杂项-Java:标签库 1.返回顶部 1. JSP标签库,也称自定义标签库,可看成是一种通过JavaBean生成基于XML的脚本的方法.从概念上讲,标签就是很简单而且可重用的代码结构. ...
- spring 监听器 IntrospectorCleanupListener简介
转自:https://blog.csdn.net/ywb201314/article/details/51144256 其中JavaBeans Introspector是一个类,位置在Java.bea ...
- z-index 、层叠上下文、层叠级别、z-index失效
一.z-index z-index默认处于非激活状态,只有定位元素(即position:relative/absolute/fixed时)才会被激活. z-index与层叠上下文关联. 当z-inde ...