ASP.NET 5 / Entity Framework 7 Migration for multiple contexts

In beta1 and beta2 we have to use KVM from the command line to issue migrations commands.

The problem is that the help file is a bit strange, dont blame them they working hard on all the features. But if oyu are using the vNext project with User Authentication and the localdb AND also want to use locadb for all your other stuff, you need to create more dbcontexts, and then the simple tutorial commands lines just dont work any more

Make sure you have KVM/ K installed in Windows and that you can use k. Then go into the projects folder and do the following

k ef context list
That will list the contexts, obviously, but you can mark and copy the one you need.

k ef migration (command[eg. add]) -c (context[paste]) (command[eg. initial])
Oh, yea. Pretty simple right? After trying to work that out for about 4 hours HOW to tell migration which context to use, because the help does not list the -c option! :)


For example, to create a migration scaffold:

k ef migration add -c Kula.Com.DBContexts.Main initial

apply the migrations. (Note, we only used one command here)

k ef migration apply -c Kula.Com.DBContexts.Main

Comments