generate models from a database in an ASP.NET MVC application  Edit
 Edit
                    
                    
                    
To generate all models from a database in an ASP.NET MVC application, you can use the Entity Framework's reverse engineering feature known as Scaffold-DbContext. This command creates entity classes and a DbContext class based on the schema of the existing database. Here's how you can do it:
Install the required NuGet packages: 
Microsoft.EntityFrameworkCore.Tools and 
Microsoft.EntityFrameworkCore.SqlServer
 
Open the Package Manager Console: In Visual Studio, go to Tools ? NuGet Package Manager ? Package Manager Console. Run the Scaffold-DbContext command
Scaffold-DbContext "ConnectionString" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
 
            
         
                         30 March 2024 |
 30 March 2024 |  1888
1888