[英]How do I instruct entity framework to choose migrations based on the current database?
So when a developer starts up our application locally, it will be against a blank, localhost database. 因此,当开发人员在本地启动我们的应用程序时,它将针对空白的localhost数据库。 But in production we will first need to migrate all of the old ASP.NET Membership Framework tables and data to the new ASP.NET Identity framework tables.
但是在生产中,我们首先需要将所有旧的ASP.NET Membership Framework表和数据迁移到新的ASP.NET Identity Framework表。
How can I write EF6 migrations to consider this? 如何编写EF6迁移来考虑这一点? Also, our existing production database has no __Migration table in it.
另外,我们现有的生产数据库中没有__Migration表。
When moving from Identity to Membership with data to be ported from old tables : You can create the tables that are according to Identity schema using SQL scripts. 从身份迁移到成员资格时,要从旧表移植数据 :您可以使用SQL脚本根据身份架构创建表。 Else if you change your app to use Identity, running and creating user a first time will create the tables for you via code first.
否则,如果您将应用程序更改为使用身份,第一次运行和创建用户将首先通过代码为您创建表。 You can then copy the data from the old tables through a console application or via SQL scripts.
然后,您可以通过控制台应用程序或SQL脚本从旧表中复制数据。
If you want to run migrations to create a new Identity tables before you run your application, you can do it by running the following steps - Enable-Migrations - Add-Migration - Update-Database 如果要在运行应用程序之前运行迁移以创建新的Identity表,则可以通过运行以下步骤来完成它-启用迁移-添加迁移-更新数据库
This will create the empty tables for your according to your DbContext. 这将根据您的DbContext创建空表。 If it extends from IdentityDbContext, it will create the tables according to Identity schema along with the _MigrationHistory table.
如果它是从IdentityDbContext扩展的,它将根据Identity架构和_MigrationHistory表一起创建表。 Hope this helps
希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.