How can I run an Entity Framework 7 migration on a remote database using Powershell? How can I run an Entity Framework 7 migration on a remote database using Powershell? powershell powershell

How can I run an Entity Framework 7 migration on a remote database using Powershell?


At the moment there is no way you can use pure PowerShell to do this because a utility like migrate.exe does not exist yet and importing the EF PS modules is not possible as they require a Package Manager PowerShell Host.

Here are some ideas how you can update a remote db in EF7:

One thing you could do is use the package manager console commands from within VS as usual to update the remote db. You can create a second context that has the remote db connection string and use the update-database command specifying the context to use. These commands require the following package in EF7:https://www.nuget.org/packages/EntityFramework.Commands/. I have done this successfully in a class lib project.

Another solution would be to use DNX commands by creating a DNX project instead of a classic one. DNX projects are not just for web sites, it is just another type of project. Here is a link that shows how to create a console app DNX project:http://docs.asp.net/en/latest/dnx/console.html.So with this type of project you can use the provided DNX commands that you seem to be aware of.

I hope this helped. Maybe we can give more help if you describe your situation and your end goal in more detail.


Answer too long as a comment, so adding it here...

Have you looked at this article and the links in the answer?

From that answer

The problem with importing the module into a PowerShell console is that I believe the module expects to run in a context where it has a Visual Studio DTE object available. That environment is the NuGet Package Manager Console. This issue has been brought up before. Check out this blog post and this SO question.

This blog post shows how to write code that does migrations.

What might be helpful for readers of this question is what you have tried, what is not working, and other information that might help solve your problem.