是否可以简化迁移? [英] is it possible to make migrations simplified ?

查看:80
本文介绍了是否可以简化迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中,我们在迁移过程中执行了诸如创建表,删除索引之类的工作(假设我们有数百个迁移文件)。
现在我想在生产服务器上进行部署,是否可以像在1个文件中那样创建简化的迁移,以总结开发中的所有更改?

During development we did such things as create table, drop index, etc in our migrations (let say we have over hundreds migrations file). Now I want to deploy on production server, could I create simplified migration like in 1 file to summary all of the changes on my development ?

澄清一下,我举一个例子:
迁移1-创建表Student
迁移2-将Student_name重命名为student_full_name
迁移3-重命名地址到student_address

to clarify I give example : migrations 1 - create table student migrations 2 - rename student_name to student_full_name migrations 3 - rename address to student_address

现在我想拥有一个更好的迁移文件,例如,当我们创建学生表时,我们已经具有正确的字段名(带有 student_full_name和 student_address字段的学生)

now I want to have a better migration file like when we create student table we already have correct field name (student with field student_full_name and student_address)

如何在dotnet ef core 2.1中做到这一点?

how to do that in dotnet ef core 2.1 ?

推荐答案

我会尝试以下(备份后)
记下生产数据库
中迁移表中的版本号
从代码
中删除所有早于迁移的版本,将连接字符串设置为生产数据库
添加迁移。

I would try the following ( after backing up ) take note of the version number in the migrations table in the production database delete all the migrations older than that from the code set the connection string to the production database add a migration.

这篇关于是否可以简化迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆