Database changes with ASP.NET MVC 5

5

I'm starting some independent projects using ASP.NET MVC 5 with Entity Framework, and more learning from technology. And at the moment I had a great doubt.

I used the generated code through a connection to the database, creating an ADO.NET Entity Data Model (edmx). And it creates the object classes of the whole database. However, I needed to make some changes to the database, such as adding more tables, removing some columns and Foreing Key, and adding others.

What now? How does my code look, outdated? Having already created Controller, and views. Is there any way to do update, or do I have to make the changes all at hand?

    
asked by anonymous 02.09.2014 / 03:12

1 answer

4

Now what? How does my code look, outdated? Since I've created Controller, and views.

Exactly, at the Views level of Controllers , but Controllers may be affected if there is data load of dependent entities , such as DropDowns mounted on Controller , for example.

Is there an update, or do I have to make the changes all at hand?

It does, but this way can be a bit drastic, which is using Scaffolding , that is, allowing Visual Studio to generate it back to you. In this case, your files may be overwritten. Before trying Scaffolding , I recommend making a backup of your project.

There are two ways to do this:

  • Right-clicking the Controllers directory > Add > Controller ...
  • Using a NuGet package such as MvcScaffolding .

Through this method, Controllers and Views can be generated from your Model settings.

To learn more, I recommend reading:

02.09.2014 / 08:31