I've got a view that I'm editing in the model designer. It has a bigint view_id field that I would like to be the primary key, but when importing it I get 2 text fields set as pk (Cylinders and Liters).
Based on this post, I change the pk to my view_id field in the entity designer, and get the following errors:
Problem in mapping fragments starting at line 719:Potential runtime violation of table my_view's keys (my_view.cylinders, my_view.liter): Columns (my_view.liter, my_view.cylinders) are mapped to EntitySet VehicleToEngineConfigByBaseVehicleViews's properties MyView.Liter, MyView.Cylinders) on the conceptual side but they do not form the EntitySet's key properties (MyView.ViewId).
Problem in mapping fragments starting at line 719:All the key properties (MyView.ViewId) of the EntitySet VehicleToEngineConfigByBaseVehicleViews must be mapped to all the key properties (my_view.cylinders, my_view.liter) of table my_view.
Do I need to change something else to alter the primary key for my view?
Errors with view primary keys
-
- Posts: 5
- Joined: Wed 08 Jun 2011 18:33
Re: Errors with view primary keys
I managed to edit the edml file manually and change the key. Updating the view still keeps the new key, so I'm all set.
Re: Errors with view primary keys
Please confirm that the issue is solved.
Be aware that Entity Developer (*.edml, the Devart Entity Model item) allows editing storage part (SSDL) of the model in the design-time.
Be aware that Entity Developer (*.edml, the Devart Entity Model item) allows editing storage part (SSDL) of the model in the design-time.
-
- Posts: 5
- Joined: Wed 08 Jun 2011 18:33
Re: Errors with view primary keys
After a little looking around I wasn't able to find a way to do it in the designer.
My fix was to manually tweak the SSDL's Key sections in the edml so that it matched my desired pk.
My fix was to manually tweak the SSDL's Key sections in the edml so that it matched my desired pk.
Code: Select all
...
<EntityType Name="my_view">
<Key>
<PropertyRef Name="view_id" />
</Key>
<Property Name="view_id" Type="bigint" Nullable="false" />
<Property Name="year" Type="varchar" Nullable="false" MaxLength="4" />
</EntityType>
</Schema>
</edmx:StorageModels>
...
Re: Errors with view primary keys
Make sure that you are using Entity Developer (*.edml, the Devart Entity Model item), go to the Tools > Entity Developer > Model Explorer window, navigate to the *.Store > Tables node in it, select the needed column of your table, press F4 (Properties) and set its Entity Key to True.tabsautobiz wrote:After a little looking around I wasn't able to find a way to do it in the designer.
This is correct.tabsautobiz wrote:My fix was to manually tweak the SSDL's Key sections in the edml so that it matched my desired pk.