28 September 2021

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


  • Go to Tools -> Nuget Package Manager -> Package Manager Console (as below image)


  • Next go to Package Manager Console and add below script and run as below image. To Update already created models via Scaffold-DbContext we need to use "Force" param as below script

Scaffold-DbContext "Server=ServerName;Database=DatabaseName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force