如何为同一项目中的多个 DB 上下文启用 Entity Framework 5(版本 5.0.0)迁移,其中每个上下文对应于自己的数据库?当我Enable-Migrations
在 PM 控制台(Visual Studio 2012)中运行时,由于存在多个上下文而出现错误:
PM> Enable-Migrations
More than one context type was found in the assembly 'DatabaseService'.
To enable migrations for DatabaseService.Models.Product1DbContext, use Enable-Migrations -ContextTypeName DatabaseService.Models.Product1DbContext.
To enable migrations for DatabaseService.Models.Product2DbContext, use Enable-Migrations -ContextTypeName DatabaseService.Models.Product2DbContext.
如果我运行,则Enable-Migrations -ContextTypeName DatabaseService.Models.Product1DbContext
不允许运行Enable-Migrations -ContextTypeName DatabaseService.Models.Product2DbContext
,因为迁移已经存在:Migrations have already been enabled in project 'DatabaseService'. To overwrite the existing migrations configuration, use the -Force parameter.