- Create or Open Project in Visual Studio.
- Then in Visual Studio go to Tools Menu -> NuGet Package Manger -> Package Manger Console -> then use below command to create a model
PM> Scaffold-DbContext "Server=Database Server Name; Database=Database Name; Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Note: In above Command update below details based on you database name and requirement
- Database Server Name: Your Database Server Name
- Database Name: Your Database Name
- Trusted_Connection=True: If you are using windows authentication. If you want to use SQL Authentication then add your login details in place of "Trusted_Connection=True".
- -OutputDir Models: The -OutputDir parameter specifies the directory where we want to generate all the classes which is the Models folder in this case.
No comments:
Post a Comment