I have created a database first, then created an Entity Data Model (.edmx) file. Now I've added some validation to a few of my Model files (ending with *.cs).
Now I did no changes in the "database", just added a View for multiple tables that join together a few tables that are relational to eachother. That is, in "Server Explorer" -> "Data Connections" -> "View" -> "Add New View" to create a Joined View so that multiple tables can be join into one view.
Also, this has happened just by dragging the Diagram to "look good" so I can easily see how they relate and then right after I noticed all my validation were, yet again - GONE. I'm guessing this is not the only thing that will "disappear" whenever I do some changes that in reality are no changes to the actual database.
[Required, MaxLength(50, ErrorMessage = "Title can only be 50 characters long")]
public string Title { get; set; }
This line is removed when I just realign my Diagram, or whenever I do something that does not alter this specific Model in the database whatsoever. I did not add a new Column, I did not change a not on the database, I did not drop anything. I dragged the Diagram and I added something not relative this Model.
How do I stop this from happening? Or is validation the last thing you do? Shouldn't matter, because then after a project has been finished you want to add another table (not altering old ones) you have to recreate validation again and again? Sounds like a pain in the ass. Considering you could have 200 models and plenty of validation on each of them, not to speak of all the "Regular Expressions" that takes some time to write.
To verify, I just tried it again. Added that line over there to one of my Model.cs and dragged my "View" on the Diagram one milimeter and it recreates everything.