I have an ntier solution that has a Domain project for my POCO classes. I want to create a database with some table fields configured for a specific length. Now I see two ways to do this: either data annotations in the POCO classes themselves, or using the OnModelCreating method in my DbContext, but the best way?
My problems with the OnModelCreating approach are that this is specific to the Entity Framework. If I switch to another ORM, the database congruence will be lost if I do not repeat its implementation.
With the Annotations approach, I eventually clutter up my models and worry that they lose the POCO tag. I'm also not sure that other ORMs will respect Annotations. On the other hand, all the information about how the database should look like is tied to a model that is easy to maintain.
Any thoughts pointing me in the right direction?
James source share