Almost working. Only one problem still remains.
This fields have not been displayed in the corresponding iput fields while loading my "View"
[DataType(DataType.Date)]
[Display(Name = "Ínicio do contrato")]
public DateTime? DataInicio { get; set; }
[DataType(DataType.Date)]
[Display(Name = "Fim do contrato")]
public DateTime? DataFim { get; set; }
This model properties are not empty, but don't appear in View
<div class="form-group">
@Html.LabelFor(model => model.DataInicio, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataInicio, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DataInicio, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DataFim, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataFim, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DataFim, "", new { @class = "text-danger" })
</div>
</div>
I Found out the solution of Entity Frame work Problem.
This is the error message:
An error occurred while processing your request. Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.
It is caused by ausence of field to represent the Primary Key of register in View while editing register.
His can be solved by putting Hidden input of primary key.
@Html.HiddenFieldFor(model => model.ID)
Doing this, it will fill missing key, and every thing works fine.
your DataFormatString includes the seconds {0:hh:mm:ss}
Id also use DateType instead and you can avoid the regex
This will work for what you need
Model
or try this regex