Closed gh5692 closed 6 years ago
What type of project is that?
Can you maybe share the project?
I'm not allowed to share the project but it's a .NET Framework 4.7 Class Library project.
Can you show me the top of the csproj file?
Here is an excerpt of the csproj file.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccLocalPath>.</SccLocalPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapper, Version=1.50.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.1.50.4-alpha1-00070\lib\net451\Dapper.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="LinqKit, Version=1.1.9.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
<HintPath>..\packages\LinqKit.1.1.9.0\lib\net45\LinqKit.dll</HintPath>
</Reference>
<Reference Include="Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL">
<HintPath>..\packages\Oracle.ManagedDataAccess.12.2.1100\lib\net40\Oracle.ManagedDataAccess.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL">
<HintPath>..\packages\Oracle.ManagedDataAccess.EntityFramework.12.2.1100\lib\net45\Oracle.ManagedDataAccess.EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
With just this package installed, I am unable to reproduce - what exact VS version are you using? I am using 15.4.4. I think your VS install may be broken...
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net47" />
</packages>
Microsoft Visual Studio Professional 2017 Version 15.4.5 VisualStudio.15.Release/15.4.5+27004.2010 Microsoft .NET Framework Version 4.7.02053
I'll run a repair and let you know the results.
I do not have the guts to move to 15.4.5 ...
I created a new project and did a reverse engineer using the "ADO.NET Entity Data Model" "Code First from database" option. I don't get the error for this project so I'm going to hold off on the repair. I wonder if there is a conflict with another tool, a problem with the project or perhaps something with the code first classes causing the issue.
Ok, closing for now
The issue was the project containing the context was not set as the StartUp project. If I change it to the startup project the error is not raised and the diagram opens as expected.
Thanks for following up - nice to know!
@gh5692 thanks for the tip on setting the library as the StartUp project. However, now I get the following error:
A constructible type deriving from DbContext could not be found in the selected file
The selected file is an abstract class that inherits from DbContext, but also derives from a custom interface. I commented out the custom interface and I still get the same error above.
I am using:
@ErikEJ, thank you for your time and a great tool.
@HMoen Is an abstract class constructible?
Doh, removed abstract keyword and added a parameter less ctor and it works beautifully.
Thanks @ErikEJ !
I had the same InvalidCastException
, so I tried to set the project as startup project as suggested by @gh5692 and now I have an alert when I try to View Entity Data Model (Read-only) on my DbContext subclass : Sequence contains no matching element. Unfortunately, there's no stack trace with this alert. 😕
Visual Studio version 2017 15.6.6 EF Power Tools version 0.9.35
Hello,
I'm facing this error on Visual Studio 2019 version 16.2.1. After installed the extension, I receive the following error message when I try to generate views:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FFB2E715-7312-4B93-83D7-D37BCC561C90}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at Microsoft.DbContextPackage.Extensions.ProjectExtensions.GetProjectTypes(Project project) at Microsoft.DbContextPackage.Extensions.ProjectExtensions.IsWebProject(Project project) at Microsoft.DbContextPackage.DbContextPackage.GetUserConfig(Project project, String assemblyFullName) at Microsoft.DbContextPackage.DbContextPackage.DiscoverUserContextType(Type& systemContextType)
My project type is Class Library and is the startup project.
Any suggestion?
Regards
Hi Guys,
I think I found the solution: my solution has some class libraries projects and two mvc websites (api and web).
Looking to power tools source code, it accepts only two kinds of projects as follow:
` public const string WebApplicationProjectTypeGuid = "{349C5851-65DF-11DA-9384-00065B846F21}"; public const string WebSiteProjectTypeGuid = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}";
public static bool IsWebProject(this Project project) { DebugCheck.NotNull(project);
return project.GetProjectTypes().Any(
g => g.EqualsIgnoreCase(WebApplicationProjectTypeGuid)
|| g.EqualsIgnoreCase(WebSiteProjectTypeGuid));
}`
To make extension to work perfect, I set one of my web projects as Start up project, and success!
Rergards
I am using vs2019, v16.3.7. My project that has the DbContext derived class is not the startup project. When I set it to the startup project, I still get the error.
Top of project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net47;net48</TargetFrameworks>
<AssemblyName>DT.CustomerModel</AssemblyName>
<PackageId>DT.CustomerModel</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Getting the following error: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FFB2E715-7312-4B93-83D7-D37BCC561C90}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at Microsoft.DbContextPackage.Extensions.ProjectExtensions.GetProjectTypes(Project project) at Microsoft.DbContextPackage.Extensions.ProjectExtensions.IsWebProject(Project project) at Microsoft.DbContextPackage.DbContextPackage.GetUserConfig(Project project, String assemblyFullName) at Microsoft.DbContextPackage.DbContextPackage.DiscoverUserContextType(Type& systemContextType)
Any help is greatly appreciated.
@cj-carroll Please dont post new issues in closed ones. Your issue is a duplicate of #62
I get the following error when using the context menu "Entity Framework"->"View Entity Data Model (Read-only)".
_System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FFB2E715-7312-4B93-83D7-D37BCC561C90}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (ENOINTERFACE)). at Microsoft.DbContextPackage.Extensions.ProjectExtensions.GetProjectTypes(Project project) at Microsoft.DbContextPackage.Extensions.ProjectExtensions.IsWebProject(Project project) at Microsoft.DbContextPackage.DbContextPackage.GetUserConfig(Project project, String assemblyFullName) at Microsoft.DbContextPackage.DbContextPackage.DiscoverUserContextType(Type& systemContextType)
Using, VS 2017 Entity Framework 6.2.0 Target framework net47