I need help.
When i'm trying to install Entity-framework to my class library in my solution, i'm getting an error:
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///D:#work#web\DanceClubCMS\packages\EntityFramework.5.0.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies.
Не удается найти указанный файл." => (translate from russian - file not found)
At D:#work#web\DanceClubCMS\packages\EntityFramework.5.0.0\tools\install.ps1:10 char:34
+ $appDomain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
please help me. How can i fix that problem?
I found the solution. The problem was in way to my project 'file:///D:#work#web\' character '#' its a bad practice... thanks.
Related
Migration can be enabled in the main project but I receive error in data layer part.
Here it is :
PM> enable-migrations
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///F:\MVC-Projects\testWebApplication1\pack
ages\EntityFramework.6.4.4\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. The system cannot find the file
specified."
At F:\MVC-Projects\testWebApplication1\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:62
$utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll))
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : DotNetMethodException
You cannot call a method on a null-valued expression.
At F:\MVC-Projects\testWebApplication1\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:50
$dispatcher = $utilityAssembly.CreateInstance <<<< (
CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///F:\MVC-Projects\testWebApplica
tion1\packages\EntityFramework.6.4.4\tools\EntityFramework.PowerShell.dll' or one of its dependencies. The system cannot find the file specified."
At F:\MVC-Projects\testWebApplication1\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:31
$domain.CreateInstanceFrom <<<< (
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : DotNetMethodException
Solved!
I used these commands in the Nuget console:
Uninstall-Package EntityFramework -Force
Install-Package EntityFramework -Version 6.1.2
Enable-Migrations
I'm relatively new to dot net core and EF core. In Package Manager Console, when I type 'EntityFrameworkCore\Add-Migration Initial' I get the following error.
PM> EntityFrameworkCore\Add-Migration Initial
Both Entity Framework Core and Entity Framework 6.x commands are installed. The Entity Framework Core version is executing. You can fully qualify the command to select which one to execute, 'EntityFramework\Add-Migration' for EF6.x and 'EntityFrameworkCore\Add-Migration' for EF Core.
EntityFrameworkCore\Add-Migration : Exception calling "CreateInstanceAndUnwrap" with "8" argument(s): "Could not load file or assembly
'Microsoft.EntityFrameworkCore.Design.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file
specified."
At line:1 char:1
+ EntityFrameworkCore\Add-Migration Initial
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Migration], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException,Add-Migration
I've googled the error but have yet to find any working solutions. Any ideas? My machine is 64 bit running Windows 10. I am using VS 2017 professional 15.5.2
Many thanks
I've been using VS2015CTP now I decided to upgrade it to VS2015 Community RC For some unknown reason migrations on my projects stopped working.
In Visual Studio 2015 I get the following message>
PM> update-database
Exception calling "LoadFrom" with "1" argument(s): "The specified path, file name, or both are too long. The fully qualified file name must be less
than 260 characters, and the directory name must be less than 248 characters."
At G:\Projects\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:5
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PathTooLongException
You cannot call a method on a null-valued expression.
At G:\Projects\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:5
+ $dispatcher = $utilityAssembly.CreateInstance(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "CreateInstanceFrom" with "8" argument(s): "The specified path, file name, or both are too long. The fully qualified file name
must be less than 260 characters, and the directory name must be less than 248 characters."
At G:\Projects\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:5
+ $domain.CreateInstanceFrom(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PathTooLongException
PM>
If I open the solution in VS 2013 and run the above command everything works fine.
Is this some bug in VS, did it lose reference to something?
Is there a way to activate some sort of more extensive log, I really don't feel into debug EF.
Thanks
Edit:
I think this has something to do with the way Nuget is handled in Visual Studio 2015, it seems it doesn't look at nuget.config the same way.
I have all the packages across several solutions in the same folder, to do this I use a nuget.config under .nuget folder with:
<config>
<add key="repositoryPath" value="G:/Projects/packages" />
</config>
for some reason it seems that VS2015 is not handling this the same way as VS2013 because it tries to download the packages to the folder packages under the solution folder.
Downgraded the Entity Framework version from 6.1.3 to EF 6.1.2 and now it works.
https://github.com/aspnet/EntityFramework/issues/1950
Another reason can be in using EF in two or more projects (https://github.com/NuGet/Home/issues/528)
Temporary solution: Comment
<package id="EntityFramework" version="6.1.3" targetFramework="net46" userInstalled="true" />
of all its "packages.config" leaving uncommented only the project you want to work with Migrations.
Issue stems from having multiple projects referencing EF.
None of the existing answers worked for me. The only way I could resolve was to unload all projects referencing EF other than the one I was running Update-Database on.
This is caused by a NuGet bug
See Enable Migrations Error
The suggested workarounds are
Install an updated NuGet client that resolves this issue https://nuget.codeplex.com/releases/view/615507
Download this patched version of EntityFramework.psm1
EntityFramwework.psm1
Copy it into the packages\EntityFramework.6.1.3\tools directory, restart Visual Studio, and try again.
Unload other projects that reference Entity Framework
So that the only loaded project that references Entity Framework is the one that contains your EF model
This error has perplexed me for the last few days and can find little to no information on Google regarding this. This started the other day when I was assigned a new laptop by work and I'm essentially running this on a clean install of Windows 7 x64 with VS2012 Update 1.
Whenever I start up a project using Entity Framework 5 or 6-alpha, this exception gets thrown to the package manager console:
New-Object : Cannot find an overload for "Version" and the argument count: "2".
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:5 char:46
+ if ($PSVersionTable.PSVersion -ge (New-Object <<<< Version #( 3, 0 )))
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Test-ModuleManifest : Invalid Module Manifest path '<project path>
\packages\EntityFramework.5.0.0\tools\'. The path argument must resolve to a single file in the file system with a '
.psd1' extension. Please fix the path specification and try again.
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:14 char:34
+ $thisModule = Test-ModuleManifest <<<< (Join-Path $toolsPath $thisModuleManifest)
+ CategoryInfo : InvalidArgument: (C:\Users\stephe...rk.5.0.0\tools\:String) [Test-ModuleManifest], InvalidOper
ationException
+ FullyQualifiedErrorId : Modules_InvalidModuleManifestPath,Microsoft.PowerShell.Commands.TestModuleManifestCommand
Import-Module : Cannot bind argument to parameter 'Name' because it is null.
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:31 char:18
+ Import-Module <<<< $thisModule
+ CategoryInfo : InvalidData: (:) [Import-Module], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ImportModuleComma
nd
I can get rid of this error by editing the package scripts manually, but that feels like it would be the wrong approach. There are also multiple instances of it checking the Powershell version in this manner so I'm suspecting it's something that's wrong with my computers's configuration.
This is affecting multiple ASP.NET MVC 4 projects of mine targeting .NET 4.5. I can't run any Entity Framework commands such as Enable-Migrations or Update-Database as a result of this error. Any clues will be greatly appreciated.
I finally got it to work, it was as simple as upgrading to PowerShell 3.0. That kinda makes the version detection pointless, but hey, at least it works.
I have installed MvcScaffolding without any issues but when I try to execute a scaffold request I get the error "DbContext.Task.t4" does not exist along with other files that are missing. I have a model called Task which I think its referring to but I am at a loss on how I fix this error?
"Scaffold Controller Task -ModelType Task -ControllerName
TasksController -DbContextType TasksDbContext"
Install-Package MvcScaffolding
PM> Install-Package MvcScaffolding
Attempting to resolve dependency 'T4Scaffolding (≥ 1.0.2)'.
Attempting to resolve dependency 'EntityFramework (≥ 4.1.10311.0)'.
Successfully installed 'MvcScaffolding 1.0.2'.
Successfully added 'MvcScaffolding 1.0.2' to MvcApplication1.
Error
PM> Scaffold Controller Task -ModelType Task -ControllerName TasksController -DbContextType TasksDbContext
Scaffolding TasksController...
Find-ScaffolderTemplate : Could not find template 'DbContext.Task.t4' below folders ['C:\Development\MVCPLTaskmanager\MvcApplication1\packages\T4Scaffolding.1
.0.2\tools\EFDbContext']
At line:1 char:23
+ param($c, $a) return . <<<< $c #a
+ CategoryInfo : NotSpecified: (:) [Find-ScaffolderTemplate], Exception
+ FullyQualifiedErrorId : T4Scaffolding.Cmdlets.FindScaffolderTemplateCmdlet
Get-ProjectType : Cannot find a type matching the name 'MvcApplication1.Models.TasksDbContext'. Try specifying the fully-qualified type name, including namesp
ace.
At C:\Development\MVCPLTaskmanager\MvcApplication1\packages\T4Scaffolding.1.0.2\tools\EFDbContext\T4Scaffolding.EFDbContext.ps1:45 char:39
+ $foundDbContextType = Get-ProjectType <<<< ($dbContextNamespace + "." + $DbContextType) -Project $Project
+ CategoryInfo : NotSpecified: (:) [Get-ProjectType], InvalidOperationException
+ FullyQualifiedErrorId : T4Scaffolding.Cmdlets.GetProjectTypeCmdlet
Invoke-Scaffolder : Created database context TasksDbContext, but could not find it as a project item
At C:\Development\MVCPLTaskmanager\MvcApplication1\packages\MvcScaffolding.1.0.2\tools\Controller\MvcScaffolding.Controller.ps1:71 char:40
+ $dbContextScaffolderResult = Scaffold <<<< DbContext -ModelType $foundModelType.FullName -DbContextType $DbContextType -Area $Area -Project $Projec
t -CodeLanguage $CodeLanguage -BlockUi
+ CategoryInfo : NotSpecified: (:) [Invoke-Scaffolder], RuntimeException
+ FullyQualifiedErrorId : T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
ANSWER
It turns out that my model's namespace needs to be the same as the MVC project. Once I changed the namespace the scaffolding worked.
I had this same issue, but it was due to the model classes having errors in them, which caused them to not build. Thus there was no model matching the name I gave to scaffolding and it concluded that I hadn't used the correct namespace.
So...
Check your code for build errors
Make sure the namespace of your Models is the namespace of your Application