How can I create an EF Code First data model for AdventureWorks2014?

205 views Asked by At

The fact that EF does not handle the hierarchyid MSSQL data type is widely known. The problem using the AdventureWorks sample database to generate an EF data model caused by a table using hierarchyid is also quite well known and widely reported. A good proposed workaround, for read only scenarios, is to use a view in place of the 'offending' Production.Document table, and cast that column to a more acceptable type, like 'nvarchar'.

However, it seems the only avenue open for creating a Code First data model is to brutally remove the table altogether, as the EF Power Tools code generator skips the pleasantries allowing a user to select which tables to include in the model. So here, even using a view won't work, because the view depends on its base table.

Does anyone know a workaround for this that doesn't involve modifying the T4 templates by hard-coding to skip this table?

1

There are 1 answers

1
ErikEJ On BEST ANSWER

Yes, install VS 2013 Update 4, which include the latest EF Tools, and use the Code First Model from Database feature, it allows you to select which tables to generate.