2

I'm familiar with using Entity Framework commands in Package Manager Console within Visual Studio e.g.

Scaffold-DbContext "Server=Blah;Database=Blah;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer

I'd like to do the same in an external PowerShell script as part of an automation routine. How would I go about importing Entity Framework tools for use outside of Visual Studio?

1
  • "dotnet ef" perhaps? Commented Sep 9, 2017 at 11:11

1 Answer 1

2

I suggest you check out this resource as an introduction into using EF Core with existing databases:

http://www.learnentityframeworkcore.com/walkthroughs/existing-database

You can find an example in the middle for using the command line:

 dotnet ef dbcontext scaffold "Server=.\;Database=AdventureWorksLT2012;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Model

Regarding the -o option:

The -o option (or alternatively --output-dir) specifies the directory where the class files will be generated. If it is omitted, the class files will be generated in the project directory (where the .csproj file is located).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.