CommandNotFoundException in asp.net mvc 5 database migration - asp.net

I tried to run this command:
Enable-Migrations -ContextType ApplicationDbContext
And getting this exception:
Enable-Migrations : The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ Enable-Migrations -ContextType ApplicationDbContext
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am using vs 2015 community edition. Restarting and run it as administrator could not solve the issue. And if I try to run this command to reinstall Entity Framework:
Install-Package EntityFramework -IncludePrerelease
Getting this exception as well:
Install-Package : An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Path\packages'.
At line:1 char:1
+ Install-Package EntityFramework -IncludePrerelease
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Please, Give me any solution.

its case sensitive type
enable-migrations -contexttypename DBCONTEXT
you can also see the available options from
get-help EntityFramework

Related

Errors on Data migration

Add-Migration InitialCreate
While running this command , an error is coming while creating an API in ASP .NET
Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
Add-Migration InitialCreate
+ CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I do not have Migration folder as well as migration table in my database.
View -> Other windows -> Package Manager Console then run
install-package Microsoft.EntityFrameworkCore.Tools
Now run your command Add-Migration and your good to go.

add-migration : Cannot bind argument to parameter 'Path' because it is null

I want to enable migration in visual studio 2017. When I run it, I'm getting an error. The error message is:
add-migration : Cannot bind argument to parameter 'Path' because it is
null. At line:1 char:1
+ add-migration ApplyAnnotationsToCustomerName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Migration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Add-Migration.
I tried to uninstalling and reinstall EntityFramework and it didn't work.
Also my startup project is set to the project with EF.
nothing worked!!
Ohh... spent hours trying to figure this one out. I tried all the suggestions I could find and even tried what you did uninstalling and reinstalling EF. Nothing seemed to work and it was really frustrating. In the end what ultimately worked for me was how I uninstalled and reinstalled EF!
Uninstall:
PM> Uninstall-Package EntityFramework -Force
Reinstall EntityFramework:
PM> Install-Package EntityFramework -Pre
Source: https://entityframework.net/knowledge-base/14410987/entity-framework-code-first-migration-error

Xamrain Forms Maps not working as expected

I am trying to use the Xamrin forms map inteface to add custom pins acording to the doumenation here on microsoft but I am having an error it said that it should add the google play services automatically but it does not so I am trying to use the nuget.
Microsoft documentaiton
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/map
Nuget for google play sevices
https://www.nuget.org/packages/Xamarin.GooglePlayServices.Maps/
But I also get the following error.
GET https://nuget.telerik.com/nuget/FindPackagesById()?id='Xamarin.GooglePlayServices.Maps'&semVerLevel=2.0.0
Install-Package : Failed to retrieve information about 'Xamarin.GooglePlayServices.Maps' from remote source
'https://nuget.telerik.com/nuget/FindPackagesById()?id='Xamarin.GooglePlayServices.Maps'&semVerLevel=2.0.0'.
An error occurred while sending the request.
Unable to connect to the remote server
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
At line:1 char:1
+ Install-Package Xamarin.GooglePlayServices.Maps -Version 71.1610.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Strange thing is this i have it set to nuget.org

Error while installing Microsoft.AspNet.WebApi.OwinSelfHost from NuGet

I'm trying to get this: http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api running.
Therefore I need to put this into NuGet package manager console
Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
I got the following Error
Install-Package : Das angegebene Argument liegt außerhalb des gültigen Wertebereichs. (in english: The given argument is out of the valid value range.)
parametername: supportedFrameworks
at line:1 position:16
+ Install-Package <<<< Microsoft.AspNet.WebApi.OwinSelfHost
+ CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
You can find this package's dependencies on https://www.nuget.org/packages/Microsoft.AspNet.WebApi.OwinSelfHost/5.2.3 .
I continued to locate where the error comes from and found that the Newtonsoft Json package could be the problem. But since there are no dependencies or subpackages given, I cannot go any further which let me post my question here:
What to do, to solve this problem?
My project's target framework is .NET 4.5.1 and I use VS2013 with recent update and NuGet manager V2.8 (also the recent version for VS2013, I think).
Edit1: I found that e.g. my Microsoft.CSharp reference is to Microsoft.CSharp V4.0.0.0 ... for recent Json versions Microsoft.CSharp V4.0.1 or higher is needed. How do I update this? And why do I have to do this?

ASP.NET MVC Nuget Enabling-Migrations

I am learning about ASP.NET MVC5 with Entity Framework. For my learning I'm using Lynda Video tutorials and I am stuck at the Nuget Console where I have to run the following code:
Enable-Migrations -ContextType ApplicationDbContext
After i run it I got the folowin error:
Enable-Migrations -ContextType ApplicationDbContext Exception calling
"LoadFrom" with "1" argument(s): "Could not load file or assembly
'file:///C:...\Projects\Lynda MVC - Exercise Files\Ch3 -
continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.PowerShell.Utility.dll'
or one of its dependencies. Operation is not supported. (Exception
from HRESULT: 0x80131515)" At C:...\Projects\Lynda MVC - Exercise Files\Ch3 -
continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:780
char:5
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException You cannot call a method on a null-valued expression. At
C:...\Projects\Lynda
MVC - Exercise Files\Ch3 -
continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:781
char:5
+ $dispatcher = $utilityAssembly.CreateInstance(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or
assembly 'file:///C:...\Projects\Lynda MVC - Exercise Files\Ch3
- continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.PowerShell.dll'
or one of its dependencies. Operation is not supported. (Exception
from HRESULT: 0x80131515)" At C:...\Projects\Lynda MVC - Exercise Files\Ch3 -
continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:809
char:5
+ $domain.CreateInstanceFrom(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException
If you can help me with any solution it will be a big help.
Use '-ContextTypeNameswitch instead, and specify yourDBContext` class. i.e,
Enable-Migrations -ContextTypeName Someproject.DepartmentDb
For more useful switches, refer THIS
I had the same problem. My project was stored in a network drive. There are many security policies applied to my PC. I moved my project to the local hard drive, and the problem was solved.
It seems like "EntityFramework.Powershell.utility.dll" is tring to use some powershell functionality, and the system is preventing to execute such calls, maybe because the dll that is calling powershell is not a local file.
In your case, make sure that you do not have any security policy or system configuration that would prevent your system to call to the problematical extension (EntityFramework.Powershell.utility.dll).

Resources