Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update models in VS 2019 from database in Entity Framework in ASP.NET Core

By VS 2019, I created an API project (database first), everything it's working well, now I made some changes in the database like add new tables and some property and modify data type for others and so on.., the question is how to update models to match the database in SQL?

this is a screenshot for my project:

enter image description here

like image 496
Mohamed Elkast Avatar asked Oct 12 '25 20:10

Mohamed Elkast


1 Answers

Try to recreate your models via Scaffold-DbContext with "Force" param.

Scaffold-DbContext "Data Source=yoursource;Initial Catalog=yourdb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Force
like image 185
ClayMoreeee Avatar answered Oct 15 '25 19:10

ClayMoreeee