7
如何为多个上下文启用EF迁移到单独的数据库?
如何为同一项目中的多个数据库上下文启用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 …