Hi,
I'm sure most people who use the entity framework sometimes need an entity only for some business operations without it actually ever getting persisted to the database. For example, an online shop checkout wizard where you want to fill the customer and address info, but only persist it once the customer is at the end of the wizard and actually buys the product. There could be other things that I would like to save in the meantime, so I can't have my user object attached to the context, because then it will be saved as well.
Generally I use a unit of work pattern, so my context lifetime is short. The entity would have to exist between different context instances.
These are some of the possibilities I thought of so far:
- Use detached entities in-memory (session state) and attach them when you want to save them.
- Just save them anyway and later delete them when they turn out to be unwanted data.
- Use separate non-EF classes for this and convert to EF when you want to save.
Any other possibilities? Thanks for your insights.