如何在EntityFramework Codefirst中以编程方式更新数据库? [英] How to update-database Programmatically in EntityFramework Codefirst?
问题描述
CMS
。我的问题是模块的数据迁移策略,每个模块将更新在安装数据库模式时,必须在模块安装system.ok中实现数据库迁移机制,实体框架中的数据迁移
已经存在(感谢MS)但是迁移命令在包管理器控制台中运行。有没有办法以编程方式运行数据迁移
代码? 任何帮助都是非常感激的。
此类暴露了代码中的EF迁移:
System.Data .Entity.MigrateDatabaseToLatestVersion
在EF中,迁移在整个数据库上运行,但不是一个模块化的部分。
只是发现这个类:
System.Data.Entity.Migrations.DbMigrator
i am writing a simple CMS
over ASP.NET MVC framework (for college final project).my problem is with module's data-migration strategy.as each module will update the database schema when it is installed , a database migration mechanism must be implemented in module installation system.ok , data-migration
in entity framework is already there (thanks to MS) , but the migration commands run in package manager console.is there any way to run a Data-Migration
code Programmatically?
any help is very appreciated.
This class exposes the EF migrations in code:
System.Data.Entity.MigrateDatabaseToLatestVersion
In EF, migrations work on a whole database though - not modular parts of one.
Just found this class too:
System.Data.Entity.Migrations.DbMigrator
这篇关于如何在EntityFramework Codefirst中以编程方式更新数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!