Coffeehouse Thread

2 posts

Can I have simple POCO without the FixupCollection stuff?

Back to Forum: Coffeehouse
  • User profile image
    Sathyaish Chakravarthy

    This question pertains to ADO.NET Entity Framework version 4. I recall that we could have simple hand-written POCO's in ADO.NET Entity Framework version 2. I assume that things have remained the same. I want to still confirm because I see that the template generator for POCO's generates an additional fix up code.

    I want to hand-write my POCO's as simple classes with virtual properties so that the entity framework can generate proxies. I will enable proxy creation (which is on by default) so I can have change tracking and lazy loading.

    My question is: can I have them?

    More specifically, I noticed that the POCO template generator generates classes with a FixupCollection<T>. Is that necessary to have? If I make the navigational properties in my simple hand-written POCO a virtual IEnumerable<T>, will that suffice without any FixupCollection<T> stuff?

    As an alternative, I could use the POCO template generator but I do not wish to, because my model is quite large and complicated. I will need to keep making changes to the model and will need to keep editing the model class definitions. If I use the POCO template generator, every time I need to regenerate the model for some reason, it will overwrite all my custom changes.

    So, is it possible to just have POCO's in the real spirit of their name?

  • User profile image
    cbae

    In any code-generation scenario, you're supposed to use partial classes so you don't have to worry about getting your custom changes overwritten.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.