A constructible type deriving from DbContext could not be found in the selected file (EF Power Tools Beta 2 + VS 2012)) - entity-framework

I'm using VS 2012 (Ultimate) together with Entity Framework Power Tools Beta 2 and entity framework 5.0 (using nuget).
I've created a DbContext class. When I right-click on the corresponding file in the solution explorer and select "Entity Framework / View Entity Data Model (Read-only)", I get the error "A constructible type deriving from DbContext could not be found in the selected file." error in VS 2012.
I tried the workaround described at http://blogs.msdn.com/b/adonet/archive/2012/04/09/ef-power-tools-beta-2-available.aspx, but my registry does not contain the key "{BFC24BF4-B994-4757-BCDC-1D5D2768BF29}" in "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\BindingPaths\".
After restarting visual studio and following the same steps, a dialog pops up indicating "Exception has been thrown by the target of an invocation".
BTW. I'm able to execute my test application that creates the database from my DbContext and O can insert/delete/etc data in this database.
Any help/hints would be very appreciated.
Kind regards,
Merijn

Uninstalling VSCommands for Visual Studio 2012 should get things working again. Unfortunately, this extension does not play nicely with the EF Power Tools. It loads it's own version of EntityFramework.dll into the main VS process which prevents the DbContext discovery logic from working properly.

As mentioned by Brice, this may be caused by compatibility issue with Visual Studio Extensions.
Latest version of VSCommands fixes this problem. You can get if from Visual Studio Gallery.
Many thanks to Brice and EF Team for their help in diagnosing the problem!

Having seen this error intermittently even without the extensions listed in the other answers, I found deleting the solution's local .suo file worked - although this was very much a when-all-else-fails answer!

I had a similar issue with a different Visual Studio Extension. In my case it was Visual Studio Tools for Git (Version 1.0.0.0).
I just disabled the extension, restarted VS2012 and I was able to use generate the model from a code first EF project.

Related

Visual Studio 2017 Communnity Incorrectly Updates Roslyn Scripting

I am using Roslyn for application scripting via Nuget Package Manager. Setup should be rather simple. Create new project and, in Nuget manager, add Microsoft.CodeAnalysis.Sripting package. After couple of confirmations you are ready to go.
Next step should be checking for installed packages update. Currently, there are 5 updates that are shown after initial installation. Again, it is pretty straightforward to do this.
However, immediately after the update, two of those packages show yellow triangle in Reference node of the project.
I have tried to resolve this following SO and other hints but nothing helped me so far.
At the end, I have installed new VM with Windows 10 Pro (with all updates) and VS2017 Community Edition. After that new Windows Forms project (.net 4.6.1. based for x64) was created and scripting package is added. Unfortunately, yellow triangles are still there (after update).
Problematic packages are System.ValueTuple and System.Security.Cryptography. X509Certificates.
Also, after cleaning and rebuilding the solution, a number of warnings (MSB3836) - explicit binding redirect on "System..." conflicts with autogenerated binding redirect.
Solution to this problem might shed a light on problem with more complex solution that I stumbled upon after migration to VS 2017.
So, what is the reason for such behavior? Remember, this happens on new installation of OS and VS with simplest project possible.
Visual Studio 2017 Communnity Incorrectly Updates Roslyn Scripting
I got the same result with you steps. This issue only occurred on the Visual Studio 2017 not Visual Studio 2015. That should have some issue with package Microsoft.CodeAnalysis.
To resolve this issue, I would like provide you a workaround:
Update packages "System.ValueTuple" and "System.Security.Cryptography. X509Certificates" first, then update other packages.
It works fine on my side, you can check if it works for you.
In order to track this issue, I have create a new issue on GitHub:
https://github.com/dotnet/roslyn/issues/22290
If you have additional information to add, you can add comments below that issue. And you can check the feedback from this link.

Project referencing Portable Class Library gives error in Visual Studio Code

I create a console application in Visual Studio 2015 RC and add Automapper 3.3.1 using nuget to the project.
If I then add the following snippet to my project:
public class Class1
{
public void Test()
{
AutoMapper.Mapper.Map<B>(new A());
}
}
And then open the same project in Visual Studio Code preview on Windows 10 then I get a red squiggly on the Map function.
The error message says:
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.
My project is configured to use .NET 4.52 and there are absolutely no errors or warnings when building the same project using visual studio 2015 RC or using MSBuild from the command line.
Automapper is portable class library and this is what seems to trigger the problem.
Is this a known issue with Visual Studio Code or Omnisharp?
Are there any way to suppress these error messages?
Update:
I have now tested with VS Code version 0.3 and it is still not fixed.
To make it even simpler to reproduce I have also verified that the problem also exist for a ClassLibrary project containing only the 3 classes: Class1 as shown and class A and class B, which are just two dummy classes used to have something to map.
It does not matter which version of Visual Studio is used to create the project. The same problem exist if I create the class library project using VS 2013.
Maybe you added the reference in both dnx451 and dnxcore50 in project.json file.
I think the problem is Automapper did not support .NET Core 5.0, please refer this article for more detail about .NET core 5.0 and .NET framework 4.6.
http://blogs.msdn.com/b/cesardelatorre/archive/2014/11/18/what-is-net-core-5-and-asp-net-5-within-net-2015-preview.aspx.
This might be the limitation of multi-environment in .NET Core 5.0 when using available libraries. You should write by yourself or waiting for other libraries update if you want to use, otherwise, please remove dnxcore50 in project.json.
Happy coding!
This is actually a known issue with the OmniSharp-roslyn server which powers VS Code, see: https://github.com/OmniSharp/omnisharp-roslyn/issues/265
I suspect you might have better luck using the yeoman ASP.NET 5 generator to generate an ASP.NET 5 Console application.
See: http://docs.asp.net/en/latest/client-side/yeoman.html
And http://docs.asp.net/en/latest/dnx/console.html

Method Not Found : Void Microsoft.VisualStudio.PlatformUI.DpiHelperLogicalToDeviceUnits

I need to use ADO.NET Entity Model Object in my project but when I select to add the item from Visual Studio 2013 Template dialog, I instead encounter the error below.
Method Not Found : Void Microsoft.VisualStudio.PlatformUI.DpiHelperLogicalToDeviceUnits
Does anyone know what I need to do to get rid of this?
I am on a Windows 7 machine, with Visual Studio 2013 and current SDKS installed
There is a bug in the version of the designer included in this CTP that will cause the error to appear when trying to use the EF Tools.
Fix is here
http://blogs.msdn.com/b/adonet/archive/2014/08/18/visual-studio-14-ctp-3-and-entity-framework.aspx

Update in MicrosoftAjax.js is not reflect in my local Visual Studio 2005

I got java script error:
SCRIPT5022: Sys.ArgumentOutOfRangeException: Value must be an integer.
Parameter name: y Actual value was 326.739990234375.
When I testing application in IE 10 browser. I did googling and found this solution from Microsoft Support.
I have modified MicrosoftAjax.js and MicrosoftAjax.debug.js files as per above article.
But After modified the javascriptfiles, when I run the application using Visual Studio 2005, I did not get the updated MicrosoftAjax.js and MicrosoftAjax.debug.js files.
So my question is: How can I get the updated versions of these two javascripts files.
Thanks,
Ankur
Instead of hacking JS files try upgrading your project to a newer .NET framework:
http://codecorner.galanter.net/2013/05/01/solution-for-ie10-error-script5022-sys-argumentoutofrangeexception-value-must-be-an-integer/

Error when Reverse Engineer Code First with EF Power Tools Beta 2 and VS2012 Update 1

Just trying to generate POCO objects, context etc for an existing database by using the EF Power Tools Beta 2 "Reverse Engineer Code First" facility.
I'm using VS2012 Ultimate with Update 1, on Windows 7 64 bit.
I point it at my existing database and hit OK. I get the following error in my Build Output window:
One or more errors occurred while processing template 'Entity.tt'.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude(1,4) : error : A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run. The following Exception was thrown:
System.InvalidOperationException: Cannot find processor for directive 'T4VSHost'.
at Microsoft.DbContextPackage.Utilities.EfTextTemplateHost.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveDirectiveProcessor(String processorName)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, IEnumerable`1 directivesToBeProcessed)
Any ideas?
Looks like it is a confirmed issue with Entity framework and Visual Studio 2012 update 1
The link does currently contain 2 work arounds
This is a legitimate issue on the EF Power Tools, but it's not related to the CTP issue, which was resolved in the final VS Update release. A fix for the EF Power Tools is in the works.
David Obando
Entity Framework Team
i also hit this same problem. The culprit was a package called Entity Framework Power Tool Beta 3. Updated this and everything was back to normal.