Errors with view primary keys

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
tabsautobiz
Posts: 5
Joined: Wed 08 Jun 2011 18:33

Errors with view primary keys

Post by tabsautobiz » Mon 27 Aug 2012 18:58

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?

tabsautobiz
Posts: 5
Joined: Wed 08 Jun 2011 18:33

Re: Errors with view primary keys

Post by tabsautobiz » Mon 27 Aug 2012 23:55

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Errors with view primary keys

Post by Shalex » Fri 31 Aug 2012 16:16

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.

tabsautobiz
Posts: 5
Joined: Wed 08 Jun 2011 18:33

Re: Errors with view primary keys

Post by tabsautobiz » Fri 31 Aug 2012 19:05

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>
...

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Errors with view primary keys

Post by Shalex » Mon 03 Sep 2012 14:51

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.

Post Reply