none
Adding a View to the designer creates all these EntityKeys. What the?

    Question

  • Hi folks,

    I've got a simple View in my database. When i add it to the Designer, it correctly lists all the fields which the view returns ... but a number of these fields are marked as EntityKeys. I'm not sure why this is ... I definately know the View has no PK's or other Index's on it. It's not an Indexed View (yet, at least :P ) ... I'm just trying to play with a simple view of a table.

    Is this correct? do i need to show some screen shots? I feel that this is a not suppose to happen ... because it's not mimiking the the original table structure, which the view is supposed to be doing.....
    -Pure Krome-
    Monday, January 04, 2010 12:50 AM

Answers

  • By default EF marks all the non nullable columns as EntityKeys in vs2010 beta2. 

    In the RTM version I have heard that you can change that on the conceptual model using the designer and say that property 1 is only entity key and then EF designer would propagate those changes to the SSDL section and u wont loose those changes after update model from the database.
    Additionally properties on the SSDL that are not mapped to the conceptual model or columns used in the condition like TPH will not be part of entity key.

    Zeeshan
    • Marked as answer by Pure Krome Saturday, January 09, 2010 4:19 AM
    Friday, January 08, 2010 6:01 PM

All replies

  • By default EF marks all the non nullable columns as EntityKeys in vs2010 beta2. 

    In the RTM version I have heard that you can change that on the conceptual model using the designer and say that property 1 is only entity key and then EF designer would propagate those changes to the SSDL section and u wont loose those changes after update model from the database.
    Additionally properties on the SSDL that are not mapped to the conceptual model or columns used in the condition like TPH will not be part of entity key.

    Zeeshan
    • Marked as answer by Pure Krome Saturday, January 09, 2010 4:19 AM
    Friday, January 08, 2010 6:01 PM
  • By default EF marks all the non nullable columns as EntityKeys in vs2010 beta2. 

    In the RTM version I have heard that you can change that on the conceptual model using the designer and say that property 1 is only entity key and then EF designer would propagate those changes to the SSDL section and u wont loose those changes after update model from the database.
    Additionally properties on the SSDL that are not mapped to the conceptual model or columns used in the condition like TPH will not be part of entity key.

    Zeeshan
    Hi Zeeshan and fd*5 ... thanks heaps for answering this question. I _fully_ stumped me!!!! I just couldn't get my head around _why_ that was happening!!

    So that then answers it - and that (current) logic does match up to entity -> the non-nulls are all EntityKeys.

    I'm also VERY excited about hearing that this is fixed in RTM - I can't wait to try that out then.

    Also Zeeshan, any chance you could then check out my other related question (while I have your attention :)  ) ... : http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/39c6c2fa-56eb-4dc3-9273-7cde466f2021

    thanks heaps guys!
    -Pure Krome-
    Saturday, January 09, 2010 4:19 AM