Visual Studio 2015 Update 2 breaks EF reverse code engineer vsix
Asked Answered
G

9

16

After installing the latest Visual Studio 2015 Update 2, the EF power tools reverse code engineer option fails with the following error message.

One or more errors occurred while processing template 'Entity.tt'.
error : An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.ArgumentException: Empty path name is not legal.
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.OpenRead(String path)
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__66`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)

I have tried uninstalling and reinstalling the tool from Julie Lermans link to get the fixed VS 2015 vsix installer version.

Help!

Genus answered 5/4, 2016 at 8:45 Comment(2)
Why not use this instead: visualstudiogallery.msdn.microsoft.com/… ?Marte
Thanks. OK that's an alternative that works, but I'm on an existing code base so the changes that ripple through I need to think about. That's a definite fall back however I can use should a fix for this not available soon. Although I might be able to regen it in VS 2013 for now. Thanks.Genus
B
44

New one for VS2015: https://onedrive.live.com/?authkey=%21AP6uv8OLvM5qnmU&cid=FFD7F3DFCD5E1160&id=FFD7F3DFCD5E1160%2161967&parId=FFD7F3DFCD5E1160%2161965&action=locate

After the update 2: Right click on the project in Solution Explorer > Properties > Target Framework switch back to 4.5.1 and then rebuild the solution. Run now the reverse engineering tool. On my one worked properly

Bujumbura answered 26/4, 2016 at 11:16 Comment(9)
The link is broken...can this file still be found somewhere?Modiste
I found one that works... hereModiste
Switching project to .NET 4.5.1 did the trick for me. And to enable installing latest EF Power Tools on VS 2015, follow this link: linkVmail
My project was on .NET 4.5, switching it to 4.5.1 did the trick!Intracutaneous
This worked for me too, I had not used the power tools in a few years and needed to revisit them. I found that the simply downgrading the target framework version solved this issue for me. I also used the reverse poco generator too to get a best of both snapshot as the latter of which is still actively worked on.Marchpast
Works for me! Thx.Kast
I already was using 4.5.1, switching to 4.7 worked for me. Guess this answer helped me tough ;)Outstand
I am using V6 Beta 5 of the power tools and this solution worked.Selfevident
am using 2017, and today is 2019 this solution still works (y)Furnace
L
4

I'm not really sure my case match 100% your but the error is the same and the precondition too.

My original "sin" was the file configured for the CodeAnalysis was missing, so first step is "Check in the Project Properties, at the Code analysis tab if you are using an existing file".

Now the first Exception disappeared but a new one has popped out, a really unexpected OutOfMemoryException!

Taking the devenv.exe process under control I noticed it start consuming RAM very quickly (from 250MB to 2GB in less than 1 sec!) at this point, with no scientific reasons :-), I tried creating a new Empty Ruleset and associating it to the Project and it incredibly started working again!!

I hope this can help you.

Lanettelaney answered 20/4, 2016 at 21:40 Comment(2)
Somehow generated model, but DbSet names and navigations properties in plural mode, although pluralizing conventions are removed.Deleterious
this is because the Update 2 removed any version of "EF.Utility.CS.ttinclude" you have in your PC and replace with its brand new version which is completely different. My solution for this kind of issue (since I used EF) has always been to hardcopy any ttcinclude used within the project to be sure any further "regeneration" will reuase the same code base independently by the VS usedLanettelaney
E
4

Setting the project as startup project helped me get around this error.

Embalm answered 4/9, 2017 at 6:30 Comment(0)
W
1

Looks like the EF6 Power Tools needs some love from somebody. It is well documented one has to change the .vsix zip packet before it will install into VS2015.

It really feels like this has significant stability issues. After lots of variations on a theme, doing the following, pushes the tool into repeatable issues ...

  1. start new proj. and set target framework to 4.5.1
  2. add a app.config
  3. Install-Package entityframework -ProjectName MYPROJ
  4. [RIGHT-CLICK][Entity Framework][Reverse Engineer Code First (RECF)]
  5. Choose and connection and database This works repeatable with no issues, and kickout (RECF) again and agian at this stage repeatably works.

  6. [RIGHT-CLICK][Entity Framework][Customise Reverse Engineer Templates] and add in the .t files. Repeating the step 4 RECF works repeatably.

  7. Now changing the context.tt in very simple e.g. simply adding a // comment

to the top of context.tt causes the step 4 RECF procedure to consistently fail. Restarting VS2015 and rebooting the box, still does not enable the step 4-RECF to work again.

Deleting the project and starting again, seems to enable the RECF process to work, BUT as soon as I import the tt's and then make a change to a .tt, then there is spiral of different issues in the output ...

either

Insufficient memory to continue the execution of the program #

OR

An exception was thrown while trying to compile the transformation code

OR

One or more errors occurred while processing template 'Entity.tt'. error : An exception was thrown while trying to compile the transformation code. The following Exception was thrown: System.ArgumentException: Empty path name is not legal.

At this resource,
https://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d, there are people commenting various similar issues, but overall I this tool unstable, unreliable and difficult to use in stable repeatable way.

Windy answered 30/10, 2016 at 19:38 Comment(0)
N
1

Edit your .Net Framework to 4.5, To do Right Click on Project> Properties > Target Framework. Now try 'Reverse Engineer CodeFirst'.

Nostradamus answered 27/9, 2018 at 9:19 Comment(0)
T
1

Just open Properties tab of your project and remain it opened while running "Reverse Engineering Code First". I don't know why exactly, but it works.

Facing "Out of Memory" exception, try to temporary unload all unrelated projects in the solution. For complex databases encapsulate all your EF-related code to separate project and attach this project to separate solution, then use created solution when you need to run "reverse engineering code first".

Tabbie answered 25/3, 2019 at 10:16 Comment(0)
R
0

The problem is that the tool does't automatically download the Entity Framework package, which breaks the rules in the default Code Analysis rule set. So the workaround is first to manually install the Entity Framework package and after that to run Reverse Engineer Code Generator.

Rachellrachelle answered 21/4, 2016 at 8:22 Comment(2)
Already have the EF package in the project and I could regen fine before Update 2 was applied. EF package is still there.Genus
My project, too, already had EntityFramework.dll added to it, and worked well using the EF Power Tools when I installed VS2015 Update 1 installed.Husted
A
0

For me, it was as simple as another re-start of visual studio.

Apprise answered 12/7, 2018 at 11:37 Comment(0)
H
0

In my case I have updated entity framework from 4.5 to 4.6, 4.5.1 was not working. Follow following steps to fix this issue.

Right click on the project in Solution Explorer > Properties > Target Framework switch to 4.5 to 4.6 and then rebuild the solution.

Hoekstra answered 27/1, 2019 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.