For my application, I want to utilize MVC 3 and the Entity Framework.
The model will be kept in a separate assembly from the MVC application.
I have to decide whether to utilize code first or the EF to create my entities.
I may adorn members with [Required] and other symbols using code first. But what if EF has already created entities from the DB? How would I go about adding those attributes?
It will save me a lot of time to have EF construct my entities, but I want MVC to automatically fill in the validation based on how I've decorated my members. Is this all making sense? If so, how would I go about doing that?
Then, MetadataTypeAttribute is employed. You may use it in combination with incomplete classes to get the desired effects.
Additionally, if I were in your position, I would do additional study before choosing between Database First and Code First approaches. There are many more differences between the two ways than only saving time while producing entities. In order to save time, you may build code-first entities from a database using the simple program Power tools by EF.
Instead of constructing your entities automatically, I advise using Code First or converting an existing database to POCO's classes (not generating the entities, just creating them by hand and mapping them to the existing database)
Zzz-9-Zzz was discussed by Scottgu.