简体   繁体   English

如何在Package Manager控制台外部运行Entity Framework命令?

[英]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.

相关问题 是否可以从 package 管理器控制台运行 angular 命令? - Is it possible to run angular commands from package manager console? 与程序包管理器控制台中的实体框架相关的项目启动出错 - Error on Project Startup relating to Entity Framework in Package Manager Console 如何在 Visual Studio 外使用包管理器控制台 powershell - How to use Package Manager Console powershell outside visual studio 如何在Visual Studio外部使用nuget包管理器从命令行安装/更新包? - How can I use the nuget Package Manager outside Visual Studio to install/update a package from the commandline? 创建自己的Package Manager控制台命令? - Create own Package Manager Console commands? 当cmdlet提示您输入信息时,如何防止Package Manager控制台挂起? - How can I prevent the Package Manager Console from hanging when cmdlet prompts for info? 有没有办法在 Visual Studio 中为 Package 管理器控制台存储命令列表 - Is there a way to store a list of commands in Visual Studio for Package Manager Console Visual Studio和Nuget:程序包管理器控制台命令历史记录? - Visual Studio & Nuget: Package Manager Console commands history? 如何通过PowerShell或命令行运行Visual Studio 2017程序包管理器命令 - How to run Visual Studio 2017 Package Manager commands through PowerShell or command line 包管理器控制台找不到包 - Package Manager Console can't find packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM