Entity Framework 4 and Public Properties
I am working on a project and I am using Entity Framework 4 as my ORM. I am implementing POCO classes. Every example I see with EF 4 and POCOs implements all properties with public setters. Is this the only way to use POCO classes since EF 4? Do I need to publish all my setters?
a source to share
It depends on how you use your entities.
POCO objects are false (no matter what). True POCOs, which can have private or non-virtual state and are not serializable, cannot perform change tracking. The only thing you can do with them in O / R mapping is materialize them.
So people with serum talk about mapping "POCOs", there is usually some form of trade-off to track changes. They are not real "POCOs"; they are "so called POCOs".
One way to compromise is to keep the state of society alive. Then you can track changes using snapshots.
Another way to compromise is to make the entire saved state protected / virtual. Then you can track the changes through the proxy. Public properties are optional.
EF does not support parameterized constructors (yet), so installing a constructor (probably the best solution for your pure POCO case) is not an option right now.
a source to share
Use the POCO generator http://visualstudiogallery.msdn.microsoft.com/en-us/23df0450-5677-4926-96cc-173d02752313
http://blogs.msdn.com/adonet/pages/walkthrough-poco-template-for-the-entity-framework.aspx
they are virtual for tracking changes (if that's what you want)
a source to share