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

6 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!!|

  3. Needed to post you one very little word to be able to say thank you the moment again about the precious tips you have provided at this time. It is quite generous with people like you in giving freely just what a lot of people would’ve offered for sale for an e book in order to make some dough for their own end, most notably now that you might well have tried it if you decided. The tricks also served as the easy way to be aware that most people have a similar desire just as my personal own to learn significantly more around this issue. Certainly there are a lot more pleasurable periods in the future for people who go through your blog post.

  4. I simply needed to appreciate you once more. I’m not certain the things that I could possibly have taken care of without the type of points contributed by you over such topic. It became a challenging circumstance in my opinion, nevertheless taking note of the expert form you dealt with the issue took me to leap with contentment. I’m happier for this help and then hope you comprehend what an amazing job you’re getting into instructing people today through your web blog. More than likely you’ve never encountered all of us.

  5. Thank you so much for giving everyone an exceptionally breathtaking possiblity to read from this blog. It is often very beneficial plus packed with fun for me and my office acquaintances to visit your website at the very least 3 times weekly to study the new things you have. Not to mention, we’re always fulfilled considering the excellent tactics you serve. Some two facts in this post are unquestionably the most suitable we have ever had.

Leave a Reply

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

RSS
Follow by Email
Facebook
Twitter