[英]How can I run Entity Framework commands outside Package Manager Console?
I'm familiar with using Entity Framework commands in Package Manager Console within Visual Studio eg 我熟悉在Visual Studio的Package Manager Console中使用Entity Framework命令,例如
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. 我想在外部PowerShell脚本中执行相同的操作,作为自动化例程的一部分。 How would I go about importing Entity Framework tools for use outside of Visual Studio? 我将如何导入实体框架工具以在Visual Studio之外使用?
I suggest you check out this resource as an introduction into using EF Core with existing databases: 我建议您检查一下此资源,作为将EF Core与现有数据库一起使用的介绍:
http://www.learnentityframeworkcore.com/walkthroughs/existing-database 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: 关于-o
选项:
The -o option (or alternatively --output-dir) specifies the directory where the class files will be generated. -o选项(或--output-dir)指定将在其中生成类文件的目录。 If it is omitted, the class files will be generated in the project directory (where the .csproj file is located). 如果省略,将在项目目录(.csproj文件所在的位置)中生成类文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.