I’ve been seeing “Update-Database Not Recognized” a lot lately when doing Code-First projects. Fortunately, the workaround is simple. I have seen cases where this solution isn’t permanent but must be executed every time Visual Studio is opened.
Steps to Produce Error
Create a new Visual Studio Solution (VS2013, VS2015 or VS2017), add a couple .Net Framework projects with one as a Domain or Entity object library then a second as your Entity Framework Data Access library; with the latest Entity Framework Nuget package. Add your DbSet
The Error
“The term ‘update-database’ is not recognized as the name of a cmdlet, function, script file, or operable program.”
Essentially, the EntityFramework.psm1 file didn’t load and needs to be imported manually. This file is located in the packages > Entity Framework folder after installed using Nuget.
The Solution
Within Visual Studio and using the Package Management Console import the Entity Framework PowerShell module by using the import-module cmdlet.
1 |
Import-Module .\package\EntityFramework.6.1.3\tools\EntityFramework.psm1 |