none
Non primary key Identity column RRS feed

  • Question

  • Hi All,

    I have identity column (bigint and not a primary key) in the table. When I update the entity I got the exception

    Modifying a column with the 'Identity' pattern is not supported

    Then search in the web and found set StoreGeneratedPattern to 'Computed' and got worked. But now the same problem is coming. I checked in the entity model StoreGeneratedPattern is still Computed.

    What is the solution for this?



    Regards, Arun
    Sunday, May 2, 2010 1:51 PM

Answers

  • Hi Arun,

     

    Glad to see you again!

     

    Are you using EF4 in VS2010?   If so, I had a test at my lab and it works fine if we set the StoreGeneratedPattern to “Computed”.   Please note: I set not only the StoreGeneratedPattern at the conceptual model (CSDL), but also the storage model (SSDL), then the exception won’t be thrown if we try to change the identity property value.   

     

    However, I don’t think we can change the value of “Computed” column either in EF4.  Although, the value will be modified at the client side entities, when I trace the update SQL statements, the identity column is not updated.  

     

    So, are you trying to modify identity column?   

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Arunkumar.B Monday, May 3, 2010 5:57 AM
    Monday, May 3, 2010 3:54 AM
    Moderator

All replies

  • Hi Arun,

     

    Glad to see you again!

     

    Are you using EF4 in VS2010?   If so, I had a test at my lab and it works fine if we set the StoreGeneratedPattern to “Computed”.   Please note: I set not only the StoreGeneratedPattern at the conceptual model (CSDL), but also the storage model (SSDL), then the exception won’t be thrown if we try to change the identity property value.   

     

    However, I don’t think we can change the value of “Computed” column either in EF4.  Although, the value will be modified at the client side entities, when I trace the update SQL statements, the identity column is not updated.  

     

    So, are you trying to modify identity column?   

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Arunkumar.B Monday, May 3, 2010 5:57 AM
    Monday, May 3, 2010 3:54 AM
    Moderator
  • Hi Lingzhi,

    Thanks for your solution. Its working now.

    I'm not modifying that identity column in client side. At the time of inserting it will generate the number thats it. Its like a serial number. Is there any other better way to manage identity column in EF 4?

     


    Regards, Arun
    Monday, May 3, 2010 6:01 AM
  • Hi Arun,

     

    Generally, for Identity columns we set the StoreGeneratedPattern to “Identity”.   I think how to handle the identity column is determined by our real scenario.  No better methods I can figure out so far.  J 

     

    Good day!

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, May 5, 2010 9:31 AM
    Moderator