[英]how to scaffold-dbcontext to different folders?
We can run the following command that will create the context and models in the project:我们可以运行以下命令来在项目中创建上下文和模型:
Scaffold-DbContext -Connection "Data Source=somedatasource.com;Initial Catalog=mydb;Integrated Security=False;User Id=user;Password=pass;MultipleActiveResultSets=True" -Provider Microsoft.EntityFrameworkCore.SqlServer -Tables PrdSalesRegion -Context SalesRegionContext
How do we specify different output folders for context and tables?我们如何为上下文和表指定不同的输出文件夹?
When I attempt to do this:当我尝试这样做时:
Scaffold-DbContext -Connection "Data Source=somedatasource.com;Initial Catalog=mydb;Integrated Security=False;User Id=user;Password=pass;MultipleActiveResultSets=True" -Provider Microsoft.EntityFrameworkCore.SqlServer -Tables Models/PrdSalesRegion -Context Context/SalesRegionContext
Note, that the only change is:请注意,唯一的变化是:
-Tables Models/PrdSalesRegion -Context Context/SalesRegionContext
Then I get this output:然后我得到这个输出:
The context class name passed in, Context/SalesRegionContext, is not a valid C# identifier.传入的上下文类名称 Context/SalesRegionContext 不是有效的 C# 标识符。
How do we specify different output folders for context and tables?我们如何为上下文和表指定不同的输出文件夹?
You could add the flag -o <DIR>
.您可以添加标志-o <DIR>
。 You could also use -f
flag to override existing files while updating existing models with new fields.您还可以使用-f
标志覆盖现有文件,同时使用新字段更新现有模型。
The full command could be:完整的命令可能是:
Scaffold-DbContext "Host=127.0.0.1;Database=dbname;Username=postgres;Password=test12345"Npgsql.EntityFrameworkCore.PostgreSQL -o Entities -f
Hope this helps希望这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.