Data model
Data model and O/R conversion, using EntityFramework implementation.
You can use the Firstcode model to define the model first, generate the database through the model, or you can automatically generate the corresponding data model from the database by installing the Efpowertools (accustomed to using this method).
Construction Scaffolding
Construction scaffolding is to provide a template for data maintenance, can automatically complete the data modification and deletion of related basic code, by modifying the underlying code, you can quickly complete the basic data maintenance.
With scaffolding templates, you first need to select a model class in which to select the context class to access the database.
Model binding
In the case of data maintenance, a two-way binding between the form and the data model automatically assigns the properties of the model (implicit model bindings) when committed.
You can also make explicit model binding by calling Updatemodel (album) in the background method, if there is a problem with the binding, and if there is no exception, you can proceed with the following code:
Try
{
Updatemodel (album);
Data manipulation
}
catch (Exception ex)
{
Error handling, re-rendering the view
}
You can also use the following method
TryUpdateModel (album);
if (modelstate.isvalid)
{
Data manipulation
}
Else
{
Error handling, re-rendering the view
}
For data maintenance procedures, it is recommended to use the Ajaxfrom method (see chapter eighth Ajax).
ASP. NET MVC 4 Advanced Programming Learning Notes: Fourth Chapter model