We help IT Professionals succeed at work.

mvc entity framework

Last Modified: 2019-01-28
i just take over a mvc with entity framework project and the developer is gone.
Now I added a column in the database table, and how can i refresh the entity framework so I can continue to code with linq...?

I am not expert with any projects that using entity framework. hope you can help out.

Watch Question

This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2019

That is database-first. Just make a backup of your models in case the previous developer added code into the autogenerated classes
Jose Gabriel Ortega CastroTop-Rated Plus Freelancer (Upwork)/EE Solution Guide / CEO / Photographer
Awarded 2018
Distinguished Expert 2018

Go to the Powershell console.
Open VS and navigate to Tools/Package Manager Console
Then run Enable-Migrations (if you got an error, your developer already did this)

if the enable-migrations cmdlet works or fail you should create a new migration (from old DB to new)
add-migration UpdatedCoumnXXXX

you should review the code proposed and if you accept it just run


and that's it.

This is if you added the column programmatically if you did it on the DB follow the previous suggestion from  @Shaun Vermaak

Documentation in here: https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions