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 that the only way I can use POCO classes with EF 4? Do all my setters need to be public?
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 change tracking (if that is what you want)
It depends how you use your entities.
"POCO" entities are kind of a lie (in any framework). True POCOs, which might have private or non-virtual state and no provision for serialization, can't do change-tracking. The only thing you can do with them in O/R mapping is materialize them.
So whey people talk about mapping "POCOs", there is usually some form of compromise to allow for change tracking. They're not really "POCOs"; they're "so-called POCOs."
One way to compromise is to make all persisted state public. Then you can do change tracking via snapshots.
Another way to compromise is to make all persisted state protected/virtual. Then you can do change tracking via proxies. It is not necessary for the properties to be public.
The EF doesn't support parameterized constructors (yet), so constructor injection (probably the best solution for your case with a "pure" POCO) isn't an option right now.