scaffolding – For .NET Core 2.* using VSCode

You can scaffold the same way in VS code running in Linux, Mac OSx as you were able to do the same in Visual Studio.

Requirements

Step 1 : -After creating the project open your .csproj file and update the following line. If you are using Repository pattern with dependency injection the you have to add in both .csproj file in Web and Data folder.


  <ItemGroup>
  <PackageReferenceInclude="Microsoft.VisualStudio.Web.CodeGeneration.Design"Version="2.0.0"/> 
  <PackageReference Include="Microsoft.Composition" Version="1.0.31" ExcludeAssets="All" 
  /><PackageReference Include="System.Composition" Version="1.0.31" />
  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" 
  />
  </ItemGroup>
  
Step 2 : -Run 

dotnet restore

 and make sure your file restoration completes with no errors.

Step 3: – Open the command line tools by clicking on terminal.

Step 4: – Now you can scaffold using the following command.

dotnet ef dbcontext scaffold 'Server=Your_server;Database=Your_Db;Trusted_Connection=True;User Id=sa;Password=Your_Password;Integrated Security=false;' Microsoft.EntityFrameworkCore.SqlServer -o Models -f

3 thoughts on “scaffolding – For .NET Core 2.* using VSCode

  1. I am getting error while I am trying this.Please give me the solution.

    “error NU1107: Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 2.8.0 directly to project “

    1. The code analysis package seems to be missing. use the command

      dotnet add package Microsoft.CodeAnalysis.Common --version 2.8.0
      


      In the Web, Repository , Services and Data folder.

  2. Hello, i think that i saw you visited my web site thus i came to return the favor?.I am trying to to find things to improve my web site!I guess its good enough to make use of a few of your ideas!!|

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email
Facebook
Twitter