[英]how to scaffold-dbcontext to different folders?
我們可以運行以下命令來在項目中創建上下文和模型:
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
我們如何為上下文和表指定不同的輸出文件夾?
當我嘗試這樣做時:
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
請注意,唯一的變化是:
-Tables Models/PrdSalesRegion -Context Context/SalesRegionContext
然后我得到這個輸出:
傳入的上下文類名稱 Context/SalesRegionContext 不是有效的 C# 標識符。
我們如何為上下文和表指定不同的輸出文件夾?
您可以添加標志-o <DIR>
。 您還可以使用-f
標志覆蓋現有文件,同時使用新字段更新現有模型。
完整的命令可能是:
Scaffold-DbContext "Host=127.0.0.1;Database=dbname;Username=postgres;Password=test12345"Npgsql.EntityFrameworkCore.PostgreSQL -o Entities -f
希望這有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.