When changing a Model, how to redo Scaffolding?

Asked

Viewed 138 times

2

I have a model, called CombustivelModels, where I made a Scaffolding generating the Controller and the Views, my doubt is, when making a review on that Model, has how to update via Scaffolding the Controller and the View?

Old model:

public class CombustivelModels
{
    [Key]
    public int CombustivelId { get; set; }

    [Required]
    public decimal km_inicial { get; set; }
    [Required]
    public decimal km_final { get; set; }
    [Required]
    public decimal litros { get; set; }
    [Required]
    [DataType(DataType.Currency)]
    public decimal valor { get; set; }
}

Revised Model:

public class CombustivelModels
    {
    [Key]
    public int CombustivelId { get; set; }

    [Required]
    public decimal km_inicial { get; set; }
    [Required]
    public decimal km_final { get; set; }
    [Required]
    public decimal litros { get; set; }
    [Required]
    [DataType(DataType.Currency)]
    public decimal valor { get; set; }

    [Required]
    public string UserId { get; set; }
}

1 answer

2


You have to delete what has already been created and create again.

The act of editing the unchanged model that has already been created.

Remembering that the inclusion of an annotation in the model changes the way a @Html.EditFor<> mounts his textbox, for example.

The inclusion and exclusion of new fields and relationships do not change the view.

Updating

I advise in your case edit the view at hand, after understanding how the view works becomes very easy to do, it is worth doing as a form of learning and study

Browser other questions tagged

You are not signed in. Login or sign up in order to post.