Package Manager Console Enable-Migrations CommandNotFoundException in visual studio pro s2017 - c#

I tried to run the command 'Enable-Migrations' in the microsoft sample project https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/ with visual studio professional 2017, But I got the message:
PM> 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, verif
y that the path is correct and try again.
At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
1、I have tried the re-starting Visual Studio and re-install EntityFramework Packages using "Install-Package EntityFramework -IncludePrerelease" but these are invalid
2、I have tried upgrade my powershell to 4.9.3.5777, but it is also invalid
3、I have tried Import-Module ProjectPath\packages\EntityFramework.6.3.0\tools\EntityFramework6.psd1,but invalid
BTW,I am using EntityFramework6.3.0.

Did you install:
Install-Package EntityFramework

I resloved the question by installing EntityFramework5.0 with .net Framework4.5.

Related

Facing issue while installing Package using package Manager console in Visual Studio for ASP.NET MVC

While installing any package from Visual Studio using the Package Manager Console, I get an error - how to resolve it?
PM> Install-Package Microsoft.AspNet.MVC
Install-Package : Unable to find package 'Microsoft.AspNet.MVC' at source ''.
At line:1 char:1
Install-Package Microsoft.AspNet.MVC
CategoryInfo : NotSpecified: (:) [Install-Package], Exception
FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
In output window, it shows these messages:
[Package source] Unable to load the service index for source https://packagesource.
An error occurred while sending the request.
The remote name could not be resolved: 'packagesource'
Please add the package source from the option.
Tool -> Option -> Nuget Package Manager
Add new source and add name as you want and in source for add https://api.nuget.org/v3/index.json. and save it.

Nuget Package Manager - Update-Package NotSpecified error

I am trying to update my app's package to be compatible with .NET Framework 4.8
After I execute the Update-Package nuget command, I get an error mentioned in this link
Then after solving that issue, when I execute again the Update-Package, I'm now getting this error:
Executing nuget actions took 10.93 min
Update-Package : This collection is read-only.
At line:1 char:1
+ Update-Package -Reinstall -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
I don't know where to check this because it didn't say which library or files are affected by this error.
I tried to clean the packages, enabled verbose flag and everything that was suggested to the search but to no luck
Has somebody encountered the same and overcome this issue?
Really need help on this one.

Microsoft.EntityFrameworkCore.Tools 3.1.4. Add-Migration not work

I want to use migrations in my EF Core Lib Project.
I installed NuGet packages
Microsoft.EntityFrameworkCore 3.1.4
Microsoft.EntityFrameworkCore.SqlServer 3.1.4
Microsoft.EntityFrameworkCore.Tools 3.1.4
But the Add-Migration command never appeared in the PM console.
When I restarted Visual Studio 2019. There was an error in the PM console:
Package Manager Console Host Version 5.5.0.6473
Type 'get-help NuGet' to see all available NuGet commands.
& : The term 'C:\Users\ruslan.runchev\.nuget\packages\microsoft.entityframeworkcore.tools\3.1.4\tools\init.ps1' is not recognized as the n
ame of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the pa
th is correct and try again.
At line:1 char:45
+ ... rgs+=$_}; & 'C:\Users\ruslan.runchev\.nuget\packages\microsoft.entity ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\ruslan...\tools\init.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PM>
How can I solve this problem?

Nuget package install command throws error : Install-Package Crystal Decision -Version 13.0.3500

I have been trying to install Crystal Decision version 13.0.3500.0 into my local code But I am getting error like
**Install-Package : Package 'CrystalReports.Engine 13.0.3500' is not found in the following
primary source(s):
'http://abcv.it.vbn.net/repository/nuget-drs-ms,C:\Program Files (x86)\Microsoft
SDKs\NuGetPackages\'. Please verify all your
online package sources are available (OR) package id, version are specified correctly.
At line:1 char:1
+ Install-Package CrystalReports.Engine -Version 13.0.3500
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId :
NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand**
any clue to solve this issue or error? Thanks in advance

Npgsql exception on connection string

I cant get Npgsql connection string to work. I've tried some ways, for example
NpgsqlConnection conn = new NpgsqlConnection("Server=192.168.1.220;User Id=pgsql;Password=pgsql;Database=pgsql;");
or
var conn = new NpgsqlConnection("Host=192.168.1.220;Username=pgsql;Password=pgsql;Database=pgsql");
both throws me exception:
The type initializer for 'Npgsql.NpgsqlConnectionStringBuilder' threw an exception.
Im running Windows XP 64bit with VS 2010. I've already tried to connect from that machine to my pgsql server using ODBC or pgAdmin III - both works ok.
Could be this problem related to my Npgsql installation?
I was not able to install it with NuGet, because I got following error:
PM> Install-Package Npgsql
Installing 'Npgsql 3.2.1'.
Successfully installed 'Npgsql 3.2.1'.
Adding 'Npgsql 3.2.1' to Project.
Uninstalling 'Npgsql 3.2.1'.
Successfully uninstalled 'Npgsql 3.2.1'.
Install failed. Rolling back...
Install-Package : Could not install package 'Npgsql 3.2.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0,Profile=Client', but the packag
e does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<< Npgsql
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I've tried also to switch target framework to 4.0 or 3.5, but result was exactly the same.
So I installed Npgsql simply by extracting .dll from MSI installation, then load it as reference.
Does anyone know how to make connection string to work?
You forgot about the port. Maybe this is the cause. The standard PostgreSQL server listening on port 5432.
NpgsqlConnection conn = new NpgsqlConnection("Server=192.168.1.220;Port=5432;User Id=pgsql;Password=pgsql;Database=pgsql;");
Example Connection String
Maybe you haven't a library Mono.Security.dll. It is necessary in the older version less then 3.0 or is enabled the system firewall?

Categories

Resources