How to do Migrations in DB first approach(如何在 DB 优先方法中进行迁移)
问题描述
我正在使用实体框架 DB 优先方法,并且想知道如何在 DB 优先方法中管理迁移.我们正在手动更改数据库架构.实体框架是否可以通过任何方式将更改相应地应用于项目.
I am using entity framework DB first approach and wants to know how can i manage migrations in DB first approach. We're doing changes in database schema manually. Is there any way by which Entity Framework can apply the changes accordingly to the project.
推荐答案
我想我对 existing database 和 database first 和 model 混淆了.我的理解是,在不同的论坛搜索后,迁移只允许在代码优先的方法中.代码首先假定您永远不会手动对数据库进行任何更改.对数据库的所有更改都将通过代码优先迁移.对于具有现有数据库的代码优先也是如此.如果您首先使用现有数据库使用代码,那么它假定在第一次连接数据库后,对数据库的所有更改都将通过代码首次迁移而不是手动进行.当您使用模型而不是代码优先方法时,对数据库的任何手动更改都可以通过 Update model from DataBase 选项迁移到模型.可以通过右键单击模型来访问.
I guess I got confused between the code first with existing database and database first with model.
What I understood is, after searching in different forums, Migrations are allowed only in code first approach. Code first assumes that you will never make any changes manually to the database. All the changes to the database will go through the code first migrations.
This is true for code first with an existing database as well. If you are working with code first with existing database then it assumes that after connecting the the database for first time all the changes to the database will go through the code first migration instead of manually.
When you are using Model instead of code first approach then any manual changes to the database can be migrated to the model by Update model from DataBase option. Which can be accessed by right clicking on the model.
我希望我的理解是正确的,但欢迎任何修改或更正.
I hope my understanding is correct but any modifications or corrections are welcome.
这篇关于如何在 DB 优先方法中进行迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 DB 优先方法中进行迁移
基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
