Page 1 of 1

Errors with view primary keys

Posted: Mon 27 Aug 2012 18:58
by tabsautobiz
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?

Re: Errors with view primary keys

Posted: Mon 27 Aug 2012 23:55
by tabsautobiz
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

Posted: Fri 31 Aug 2012 16:16
by Shalex
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.

Re: Errors with view primary keys

Posted: Fri 31 Aug 2012 19:05
by tabsautobiz
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.

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

Posted: Mon 03 Sep 2012 14:51
by Shalex
tabsautobiz wrote:After a little looking around I wasn't able to find a way to do it in the designer.
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:My fix was to manually tweak the SSDL's Key sections in the edml so that it matched my desired pk.
This is correct.