Skip to content

HierarchyId does not parse valid ID which contains numbers outside of the range of Int32 #2325

@marcOcram

Description

@marcOcram

Hello,

I am aware that the classic Entity Framework is not developed anymore and may not get any bug fixes. At least this issue would be for documentation purposes.

If you have an hierarchy ID that contains a number outside the range of an Int32 it does not parse the ID and throws an exception that it is not a valid string representation of an hierarchy ID.

A workaround would be to use smaller hierarchy IDs unfortunately the default for a path_locator in file tables of SQL Server is such an ID.

Sample

const string ID = "/239196746533516.54209197962074.2160059995/";
// works, just to prove that it is a valid ID, you need the reference to Microsoft.SqlServer.Types
// var x = Microsoft.SqlServer.Types.SqlHierarchyId.Parse(ID);
// does not work
var y = System.Data.Entity.Hierarchy.HierarchyId.Parse(ID);

Stack trace

System.ArgumentException: The input string '/239196746533516.54209197962074.2160059995/' is not a valid string representation of a HierarchyId node.
Parameter name: hierarchyId
   at System.Data.Entity.Hierarchy.HierarchyId..ctor(String hierarchyId)
   at System.Data.Entity.Hierarchy.HierarchyId.Parse(String input)

Provider and version information

EF version: 6.5.1
Database provider: System.Data.SqlClient
Target framework: .NET Framework, .NET Core
Operating system: Windows 11
IDE: Visual Studio 17.14.16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions