Sknecht
Sknecht

Reputation: 1074

Trying to add migration to my Asp.net5 project with EF7

I am trying to add migration to my project but for some reasons I don’t have the command for it. When I input get-command -module entityframework in my package console the output is nothing.

My dependencies and command in my project.json looks like:

"dependencies": {
"bootstrap": "3.3.5",
"EntityFramework.SqlServer": "7.0.0-beta8",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta8",
"EntityFramework.Commands": "7.0.0-beta8"
 },

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
}

I tried it over the command prompt with “dnvm use 1.0.0-beta8” and then “dnx ef . migration add Initial”. The first one works fine but the second command gives me “Error: Unable to load application or execute command 'EntityFramework.Commands'. Available commands: web, ef.”

Does anyone have an idea what’s wrong?

Upvotes: 0

Views: 1808

Answers (1)

pg0xC
pg0xC

Reputation: 1266

You are starting well with dnvm use 1.0.0-beta8.

Entity framework 7 commands are not based on powershell any more so typing get-command won't do any help. Instead use "pure" command line. EDIT: I was wrong - EF7 beta8 has powershell commands. I haven't tried them yet. Nevertheless I still recommend dnx commands.

I think that second one should give you something like "Unrecognized command or argument '.'". I think this syntax may be from previous version of EF commands.

Run console and change directory (cd PATH_TO_PROJECT) to your project folder where project.json is. Run dnu restore at first. Then check if dnx ef gives any output. If it does display a EF7 unicorn then add migration with dnx ef migrations add initial.

You may always check ef command syntax by typing simply dnx ef.

Upvotes: 2

Related Questions