SqlClient: Edmx and Microsoft.Data.SqlClient result in HierarchyId invalid error
Describe the bug
In order to integrate the model first edmx entity framework 6 experience with Microsoft.Data.SqlClient we changed the value of the Provider attribute on the Schema element to Microsoft.Data.SqlClient. As per the instructions on https://github.com/ErikEJ/EntityFramework6PowerTools/blob/community/src/ErikEJ.EntityFramework.SqlServer/readme.md
But now the designer reports the following error:
<File Unknown>(167,34) : error 0005: The 'PrimitiveTypeKind' attribute is invalid - The value 'HierarchyId' is invalid according to its datatype 'http://schemas.microsoft.com/ado/2006/04/edm/providermanifest:TPrimitiveTypeKind' - The Enumeration constraint failed.
<File Unknown>(167,10) : error 0122: The value 'HierarchyId' is not a valid PrimitiveTypeKind. ConsoleApp1 C:\work\git\ConsoleApp1\Model.edmx 7
Tested with .NET Framework 4.8. Package version 5.1.1.
This error isn’t blocking the designer, but whenever we do any database operations through the user experience, this error is blocking the process.
To reproduce
You can clone the following solution: https://github.com/cveld/sqlclient-hierarchyid-edmx-designer-error Open up the solution file in Visual Studio and then double click the edmx file in order to kick off the designer. You will see the reported error message in the error list dialog.
Expected behavior
The error shouldn’t be present and the database features should be working as designed.
Further technical details
Microsoft.Data.SqlClient version: 5.1.1 .NET target: Framework 4.8 SQL Server version: Azure Sql Database Operating system: Windows 11 Visual Studio: 17.5.4
Additional information
We initially reported the issue to https://github.com/ErikEJ/EntityFramework6PowerTools/issues/124 but @erikej does not have any visibility or responsibility towards the Visual Studio side of things.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (12 by maintainers)
Links to this issue
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.11
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.11
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.11
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.7
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.9
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.10
- NuGet Gallery | ErikEJ.EntityFramework.SqlServer 6.6.6
Create a simple repro console app and upload as .zip or github repo. Maybe you will learn something in the process 😉
@cveld
Windows 10E Version 21H2 Build 19044.2846 Visual Studio 2019 Enterprise 16.11.26 .NET Framework 4.8.09037 EntityFramework 6.4.4 ErikEJ.EntityFramework.SqlServer 6.6.5 Microsoft.Data.SqlClient 5.1.1
*You will need to modify the pathing/insertion points as needed for VS2017 and your subscription level.
Close all VS instances.
Launch CLI with elevated permissions and do the following:
Launch an editor with elevated permissions, e.g. Notepad++, and do the following:
<xs:enumeration value="HierarchyId" />(Optional) Prior to these steps, we were seeing this error when opening the EDM Designer and when rebuilding the solution: “Error 175: The ADO.NET provider with invariant name ‘Microsoft.Data.SqlClient’ is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.” Curious that you are not. Using your editor, do the following:
<remove invariant="Microsoft.Data.SqlClient" /><add name="SqlClient Data Provider" invariant="Microsoft.Data.SqlClient" description=".NET Framework Data Provider for SqlServer" type="Microsoft.Data.SqlClient.SqlClientFactory, Microsoft.Data.SqlClient" />Open your solution in VS. Rebuild all. Open an edmx file.
Please tell us about your experience including any deviations or anomalies. If this solves your issue, please re-post the revised solution to Issue 10347962.