Visual Studio 2015 Update 2 breaks EF reverse code engineer vsix

懵懂的女人 提交于 2019-11-30 07:12:03

问题


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!


回答1:


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




回答2:


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




回答3:


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.




回答4:


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.




回答5:


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




回答6:


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.




回答7:


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




回答8:


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.




回答9:


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".



来源:https://stackoverflow.com/questions/36421344/visual-studio-2015-update-2-breaks-ef-reverse-code-engineer-vsix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!