Reputation: 2116
I may be doing things wrong here, and if that's the case, please point me to the right direction.
I am coding a migration application where I want to be able to type the Connection String I want to use at run time, and be able to Update different databases (potentially each one for a different versions).
The issue for me is that the Add-Migration command only executes through the Package Manager Console, and as I don't have a connection string set under my app.config, how would it be possible for the Entity Migration to know which version my database is at?
I fell into this issue after running the Initial migration for a certain connection string (it created the Database and tables correctly), but after, when I tried to add a second migration file, I got an error saying that there were other migrations pending.
Maybe the Entity Migration just wasn't meant to be executed out of the Package Manager Console, or with dynamic connection strings, but I need to be sure of what I am doing.
Upvotes: 2
Views: 646
Reputation: 4428
There is already such an application prepared - browse for information on migrate.exe: http://msdn.microsoft.com/en-us/data/jj618307.aspx.
And regarding your question - the ef recognizes at which migration database is very simple. It uses for that __MigrationHistory table within your database. There it has information which migrations was already applied (by MigrationId). The state of the current database and database that should be result after application of the given migration is compared by hash value stored in resx file of your migration under key "Target".
Upvotes: 2