Visual studio gives me a trace of errors that I got stuck in. I am trying to add an existing table in a database to my data model. I understand that a table must have a key, but it is not, and I cannot fix it; this is not my redevelopment database.
When I first try to add a table, I get this error:
The table / view of 'BT8_GC.dbo.SAVED_QUERY_CATEGORY' makes the primary key undefined and no valid primary key can be displayed. This table / view is excluded. to use the entity, you will need to review your schema, add the correct one and uncomment it.
Ok, ok, I will determine the keys for it and uncomment it. Here is the block that I uncommented after I manually determined the keys (I also had to add nullable = false):
<EntityType Name="SAVED_QUERY_CATEGORY"> <Key> <PropertyRef Name="SQC_CAT_ID"/> <PropertyRef Name="SQC_USER_ID"/> </Key> <Property Name="SQC_CAT_ID" Type="int" Nullable="false" /> <Property Name="SQC_USER_ID" Type="int" Nullable="false" /> <Property Name="SQC_CAT_DSCR" Type="varchar" MaxLength="50" /> <Property Name="SQC_SEQ_NO" Type="int" /> </EntityType>
No, now the designer will not open. Go back to the file and Intellisense shows this error:
Error 11002: Object type "SAVED_QUERY_CATEGORY" does not have an entity.
Ok ... Uncommenting created a new error. After adding a set of objects:
<EntitySet Name="SAVED_QUERY_CATEGORY" EntityType="IssueModel.Store.SAVED_QUERY_CATEGORY" store:Type="Tables" Schema="dbo" />
Hooray! The designer is opening! Not yet, because while it is displayed in the Tables / Views folder of the store, in the model it does not have the Entity type. I can not name it from my code. I have no errors to work with, so I tried to create a mapping of a set of objects, but this leads to the error "does not exist in metadata in space".
So what I tried. How to get this poorly designed table in my data model?