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).
But, when I'm trying to run Enable-Migrations
I see following:
Migrations have already been enabled in project 'AssemblyWithMigrations '. To overwrite the existing migrations configuration, use the -Force parameter.
So, the problem is EF trying to resolve current migration version to update database, I suppose. But database doesn't exist and it obviously fails.
The question is: how to use EF migrations for creating database if it doesn't exist? Or, what is the right way to do that using Nuget console?
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.
Thanks. :)
Update-Database
will create it automatically and apply each migration. Do you have any additional information? Getting both "No migrations configuration type was found" and "Migrations have already been enabled" should never happen for the same project. – Ysabel