[英]EF Core scaffold-dbcontext custom namespace
This is a follow-up to a similar question which was answered with a reference to this issue , which has since been closed and migrated to 2.1.0 milestone according to the linked page but I can't find it in there by searching for 'scaffold-dbcontext namespace'.这是对类似问题的后续行动,该问题已通过引用此问题得到回答,该问题已被关闭并根据链接页面迁移到 2.1.0 里程碑,但我无法通过搜索“找到它”脚手架 dbcontext 命名空间'。
Are there any plans to allow the namespace to be specified when calling scaffold-dbcontext?是否有计划允许在调用scaffold-dbcontext 时指定命名空间? - I'm developing something DB-first and routinely re-scaffolding the schema.
- 我正在开发一些 DB-first 并定期重新构建架构的东西。 Each time I then need to search/replace [namespace].Models.Models to remove the second.Models - not a big deal by any means but if I could tell the scaffolder what namespace to use it'd be handy.
每次我需要搜索/替换 [namespace].Models.Models 以删除 second.Models - 无论如何都不是什么大问题,但如果我可以告诉脚手架使用哪个命名空间,它会很方便。
(I appreciate that the scaffolder is mainly intended to be used once to migrate to code-first then never needed again but due to reasons, that's not how I'm using it.) (我很欣赏脚手架主要用于一次迁移到代码优先然后不再需要但由于某些原因,这不是我使用它的方式。)
(I would have added a comment to the original question, since this is essentially the same question but don't have enough reputation, so posted it as an answer, which was deleted, so am re-posting as a fresh question.) (我会在原始问题上添加评论,因为这本质上是同一个问题,但没有足够的声誉,所以将其发布为答案,该答案已被删除,所以我重新发布为一个新问题。)
In my case, i remarked Scaffold-DbContext works better in EF Core 3.1.5就我而言,我说 Scaffold-DbContext 在 EF Core 3.1.5 中效果更好
Scaffold-DbContext 'Server=MSSQLSEVER;Database=MyDB_TEST;Trusted_Connection=True;' Microsoft.EntityFrameworkCore.SqlServer -ContextDir MyDB -Context MyDBContext -OutputDir MyDB\Test -StartupProject Project -Force
I Obtain something like [ProjectNamespace].MyDB.Test我获得类似 [ProjectNamespace].MyDB.Test
One answer is to move to VS 2019 16.8.0 preview / Net 5.0 preview 7 / EF Core 5.0.0 preview, which I just did - scaffolding now uses the namespace of the project, in my case.Models, which is exactly as I want it.一个答案是迁移到 VS 2019 16.8.0 预览版/Net 5.0 预览版 7/EF Core 5.0.0 预览版,我刚刚做了 - 脚手架现在使用项目的命名空间,在我的例子中是.Models,这和我完全一样想要它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.