EDIT
The new EF designer (beta 1 here ) will not try to create relationships with nonexistent tables, so instead of an error and an empty model, you get a model in which invalid types / sets of entities and relationships are commented out.
**
I looked at it for AdventureWorks for Sql Server 2012, but I think itβs the same as you got in 2008R2 / The problem here is that there is a key in the Production.Document table that is of type HierarchyId, and EF is currently time does not support the type HierarchyId. EF ignores type columns that it does not understand when creating the model; however, if it does not understand the key column, it excludes the entire object from the model. For excluded objects, you should be able to find them in models when you open them using the Xml / Text editor. In this particular case, this is what it will see:
<EntityContainer Name="AdventureWorksModelStoreContainer" /> <!--Errors Found During Generation: warning 6005: The data type 'hierarchyid' is currently not supported for the target .NET Framework version; the column 'DocumentNode' in table 'AdventureWorks.Production.Document' was excluded. warning 6031: The column 'DocumentNode' on the table/view 'AdventureWorks.Production.Document' was excluded, and is a key column. The table/view has been excluded. Please fix the entity in the schema file, and uncomment. <EntityType Name="Document"> <Property Name="DocumentLevel" Type="smallint" StoreGeneratedPattern="Computed" /> <Property Name="Title" Type="nvarchar" Nullable="false" MaxLength="50" /> <Property Name="Owner" Type="int" Nullable="false" /> <Property Name="FolderFlag" Type="bit" Nullable="false" /> <Property Name="FileName" Type="nvarchar" Nullable="false" MaxLength="400" /> <Property Name="FileExtension" Type="nvarchar" Nullable="false" MaxLength="8" /> <Property Name="Revision" Type="nchar" Nullable="false" MaxLength="5" /> <Property Name="ChangeNumber" Type="int" Nullable="false" /> <Property Name="Status" Type="tinyint" Nullable="false" /> <Property Name="DocumentSummary" Type="nvarchar(max)" /> <Property Name="Document" Type="varbinary(max)" /> <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" /> <Property Name="ModifiedDate" Type="datetime" Nullable="false" /> </EntityType>--> </Schema>
Pay attention to this warning:
warning 6031: The "DocumentNode" column in the table / view "AdventureWorks.Production.Document" has been excluded and is the key column. Table / view excluded. Correct the object in the schema file and uncomment it.
Now in the AdventureWorks database, the Production.Document table refers to the Production.ProductDocument table. Since no organization has been created for the Production.Document table, EF cannot create a link from the Production.ProductDocument object and, therefore, "Production.Document" refers to the relationship, but cannot be found. "Error.
Since the Production.Document table cannot really be used "as is" with EF, the easiest workaround is to exclude this object when creating the model from the object - check all the tables except Production.Document in the wizard, and you should be good for go. EF ignores all references to this object since you excluded it, and therefore there should be no errors.
Link to a related work item on the Codetex Framework Entity Framework site
Pawel
source share