I am using ADO.Net entity framework with asp.net mvc3. I have a model which is database first. The data validation does not work in some cases, as I will explain.
I have a form, when I submit that form, some items are being validated while others are not. I am simply using a form like this,
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend></legend>
<div class="editor-label">
@Html.LabelFor(model => model.VERSION_ID)
@Html.EditorFor(model => model.VERSION_ID)
@Html.ValidationMessageFor(model => model.VERSION_ID)
</div>
<div class="editor-field">
@Html.LabelFor(model => model.ENTITY2.Name)
@Html.EditorFor(model => model.ENTITY2.Name)
@Html.ValidationMessageFor(model => model.ENTITY2.Name)
</div>
<p>
<input type="submit" value="Create" />
</p>
Now, the version_id has validation working while the Name does not. I am getting the name from another entity. Any ideas on why the validation is not working? I can input empty fields which should not be allowed as that field is required, but when i press submit i get an error.