Home > database >  How to create model classes through Entity Framework 6 scaffolding
How to create model classes through Entity Framework 6 scaffolding

Time:11-27

I have created a data access layer using data first entity framework 6. I want to create models based on these SQL server tables. I tried the following command when I ran it on the cmd prompt after navigating to the Models folder of an Asp.Net Web API project:

dotnet ef dbcontext scaffold "Integrated Security=SSPI;Initial Catalog=EmployeeDB;Data 
Source=XYZ;" Microsoft.EntityFramework.SqlServer -o Models

But it throws the following error: Could not execute because the specified command or file was not found. Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET program, but dotnet-ef does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

However similar syntax works for EF Core.

CodePudding user response:

For EF 6 Classic, you can use the tooling built into Visual Studio.

https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/workflows/existing-database

  • Related