简体   繁体   English

实体框架CodeFirst Migration

[英]Entity Framework CodeFirst Migration

I got ASP.MVC application. 我得到了ASP.MVC应用程序。 I use entity framework with default configuration (no connection string provided) so it creates .mdf file in APP_DATA . 我使用具有默认配置的实体框架(没有提供连接字符串),因此它在APP_DATA创建.mdf文件。

If I wanna move my project to another pc and try a clean depoly, should I remove this .mdf from APP_DATA ? 如果我想将我的项目移动到另一台PC并尝试干净的depoly,我应该从APP_DATA删除这个.mdf吗?

If you want to try a clean deployment , then YES. 如果您想尝试clean deployment ,那么YES。 If you copy the database file it will be reused and so the migrations are not run (again), as they are already applied. 如果复制数据库文件,它将被重用,因此迁移不会再次运行,因为它们已经应用。

Assuming that you are using Migrations in your project there should not be any problem. 假设您在项目中使用迁移,应该没有任何问题。
on new machine you can use command 在新机器上你可以使用命令
"Update-Database" in your visual studio package manager consol and it will create a new database tables on you new machine. Visual Studio包管理器consol中的“Update-Database” ,它将在您的新机器上创建一个新的数据库表。

NOTE: it will only create database schema if you need data also to get copied on to new machine you need to use some export utility. 注意:如果您还需要将数据复制到新计算机上,则需要使用某些导出实用程序,它只会创建数据库模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM