locked
No StartTracking Method in EF4.1 Templates? RRS feed

  • Question

  • I have installed the EF4.1 standalone package and used the self tracking entity t4 template to generate my entity classes.

    (Im targeting .Net framework 4 with VS2010)

     

    However in alot of the online discussions refer to using the StartTracking method to beging changetracking.

     

    In my generated classes i do not have this method? Is this method no longer included or could the T4 template I am using not be the latest version ?

     

    Or maybe I am missing something totally.

     

     

    Currently I am setting the ChangeTracker.ChangeTrackingEnabled  property manually, although I am running into problems saving changes to an object where I have added navigation property entities (M2M relationship) and everything I find in google refers to the start/stop tracking methods

     

    Any advice would be appreciated

     

    Thanks in advance

     

    Wednesday, July 13, 2011 12:06 PM

Answers

  • Hi,

    StartTracking is a part of any version of the template.

    This is placed in <yourmodelname>.cs generated file in the static class ObjectWithChangeTrackerExtensions that contains extensions to IObjectWithChangeTracker. So if your entities inherits this interface and you have this file and you are using the namespace name you should get the function. However, this only does the same as you currently do by setting ChangeTracker.ChangeTrackingEnabled.

    There is however some implications using M2M and STE, I had them myself in a project, unfortunatly I don't remember exactly how I fixed this. But it is not related to the starttracking functionality.


    --Rune
    • Marked as answer by Alan_chen Tuesday, July 26, 2011 5:53 AM
    Wednesday, July 13, 2011 12:15 PM

All replies

  • Hi,

    StartTracking is a part of any version of the template.

    This is placed in <yourmodelname>.cs generated file in the static class ObjectWithChangeTrackerExtensions that contains extensions to IObjectWithChangeTracker. So if your entities inherits this interface and you have this file and you are using the namespace name you should get the function. However, this only does the same as you currently do by setting ChangeTracker.ChangeTrackingEnabled.

    There is however some implications using M2M and STE, I had them myself in a project, unfortunatly I don't remember exactly how I fixed this. But it is not related to the starttracking functionality.


    --Rune
    • Marked as answer by Alan_chen Tuesday, July 26, 2011 5:53 AM
    Wednesday, July 13, 2011 12:15 PM
  • Hi,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 19, 2011 5:33 AM