none
prevent code change RRS feed

  • Question

  • Hi, ( c#, Entity Framework 4.1)

    Once the entity claases generated, I update a setter of some properties to add some logic; unfortunately this code disappers once I update the model.

    Is there any workaroud to preserve my manual code?

    Thanks.


    • Edited by YussafFree Sunday, December 25, 2011 8:36 AM
    Sunday, December 25, 2011 8:36 AM

Answers

  • On 12/25/2011 6:48 AM, YussafFree wrote:
    > The problem is that the property is already in the class generated by
    > the designer.
     
    Then you need to switch to Code First approach and create your own
    entities I would suspect.
     
    Sunday, December 25, 2011 5:11 PM

All replies

  • Create another file for your class using partial class definition and fill in with any new property or method you want.
    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Sunday, December 25, 2011 10:44 AM
  • The problem is that the property is already in the class generated by the designer.
    Sunday, December 25, 2011 11:48 AM
  • On 12/25/2011 6:48 AM, YussafFree wrote:
    > The problem is that the property is already in the class generated by
    > the designer.
     
    Then you need to switch to Code First approach and create your own
    entities I would suspect.
     
    Sunday, December 25, 2011 5:11 PM
  • Hi YussafFree,

    Welcome to MSDN Forum.

    I agree with darnold924, you can use  code first to create your own entity, it's more flexible.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, December 27, 2011 2:22 AM
    Moderator