How can I model a hierarchyid type column in EF code-first?

entity-framework entity-framework-6 hierarchy sql-server

Question

I'm busy with a strictly academic exercise of deriving a code-based data model for the AdventureWorks2012 sample database. My first issue is with three table columns of type hieracrhyid. The EDM wizard in VS2013 Update 4 'kindly' just ignores these columns in the POCOs it generates, and I am quite happy to directly map these columns to string properties, but I would like to have a type avialable that actually gives me hieracrhyid capabilities, downstream of the actual modle to table mapping.

In the past I have quite successfully used zgabi's contribution, i.e. a fork of the EF code that includes a HierarchyId CLR type, but I am actually trying to find a way to achieve this without modifying EF code or using the fork. This in the hope of ultimately finding a generic way to handle any column type not directly supported by EF. Here I would prefer finding, or eventually building, a mechanism for hooking into EF where I can dynamically apply conversion functions between CLR types that EF does support and column types it doesn't.

1
1
3/27/2015 7:47:02 AM

Popular Answer

That feature is not available, but if you are brave you can use the implementation in this community contribution: http://entityframework.codeplex.com/discussions/415185

0
3/26/2015 5:45:32 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow