I m having ASP.NET MVC 3 project that uses Entity Framwork 4.3 and its migrations. Now I want Entity Framework to create a database for me using migrations that I have already. When I trying to run Update-Database script it gives me the following:
Update-Database -Verbose -ProjectName AssemblyWithMigrations -StartUpProjectName WebProjectAssembly
No migrations configuration type was found in the assembly /* my name of assembly */ . (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
但当我试图运行 Enable-Migrications
时,我可以看到:
Migrations have already been enabled in project AssemblyWithMigrations . To overwrite the existing migrations configuration, use the -Force parameter.
因此,问题在于EF试图解决当前更新数据库的移民版本。但数据库并不存在,显然失败了。
问题是:如果EF 迁移不存在, 如何使用它创建数据库? 或者,使用 Nuget 控制台来创建该数据库的正确方法是什么?
In summary, what I want:
1. run command (perhaps update-database
) that will create database using my web.config file
2. all migrations will be applied on the created database in their creation order.
谢谢。 )