How can I export to script in EF Core 1.1 with .NET 4.6.1

.net .net-core ef-migrations entity-framework-core

Question

I was initially confused/surprised to see EF Core 1.1 working with the old commands for .NET 4.X, but I found it in these samples (https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db) and was fine with using these familiar commands.

Now I have a database built with EFCore 1.1 and working, commands worked great for migrations, etc.

Now it is time to roll out to production and I need to generate the script to give to the person handling to roll-out to the environment. I am now realizing that the -Script flag is not available so I try reverting to the "dotnet ef" commands and get "dotnet-ef" not found errors.

Upon further investigation it looks like I need to upgrade to Microsoft.EntityFrameworkCore.Tools.DotNet. I try this, only to get this error "Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final' uses features that are not supported by the current version of NuGet.". I don't see any upgrades available via extensions and updates so I can only assume there is a prerelease version floating around or this is only for VS2017 (I have been burned too many times moving to unreleased VS versions so holding off for now).

I noticed that nuget thinks for Microsoft.EntityFrameworkCore.Tools that 1.1.0-preview4-final is the latest version, but based on the dates I can tell that 1.1.0-msbuild3-final is the latest version. I moved to that and will just have to ignore nuget package manager wanting me to "upgrade" to the older version.

Still no luck generating a sql script. Sorry for the long winded details of how I got here, but I am still unable to generate a script for my EF Core database and it is not without effort.

Back to the original question, how can I export to script in EF Core 1.1 with .NET 4.6.1?

Any help is greatly appreciated!

1
4
2/10/2017 2:25:55 AM

Accepted Answer

The answer from another stack overflow question (https://stackoverflow.com/a/38725740/1362146) led me in the right direction.

From https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell I was able to identify the Script-Migration command. It is tough to sift through everything when there are so many different examples for different version/combinations and things are changing so frequently.

0
5/23/2017 12:17:49 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow