EF6 migrations stopped working on VS 2015 RC - entity-framework-6

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

Related

Entity FrameWork Error when adding migration to MVC dotnotcore 2.0 Application

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

Neo4j 3.3.3 Community version failed to install-service in Windows

Neo4j3.3.3 community edition, while trying to install-service its show below error. Tried on different machines. How to resolve this?
I am using Java version 1.8.0_162
I have JAVA_HOME environment variable set to C:\Program Files\Java\jdk1.8.0_162\bin
Error:
Invoke-Neo4j : Unable to determine the version of the installation at
D:\neo4j\neo4j-community-3.3.3
At line:1 char:221
+ ... t.psd1'; Exit (Invoke-Neo4j install-service)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,Invoke-Neo4j
I encountered this problem too, and got it right by setting JAVA_HOME to JRE folder, which is C:\Program Files\Java\jre-X.X.X.
I think install-service is trying to fix a jdk path by adding some postfix, which is weird and causes this problem.

not able to start neo4j server

I am using neo4j version 3.3.1 with java 1.8.0_151 on Windows 10. The log gives the following error:
Invoke-Neo4j : Failed to start service 'Neo4j Graph Database - neo4j (neo4j)'.
At line:1 char:163
+ ... odule 'C:\neo4j\bin\Neo4j-Management.psd1'; Exit (Invoke-Neo4j start)
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Neo4j
I solved this problem by changing the path to the java.dll file. I have a 64 bit machine and the file was previously in Program Files(x86) folder although it is the correct version. This was confusing Neo4J.
I just copied the java folder to Program Files and changed the environment variable to point there and it worked.

Error on Project Startup relating to Entity Framework in Package Manager Console

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.

MVC 3 Scaffolding Error when running Scaffold Controller

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

Resources