MVC 整个模型的即时自动脚手架(如动态数据)?

发布于 2024-12-27 16:16:57 字数 454 浏览 2 评论 0原文

MVC 3 是否有办法为我的整个代码优先模型自动搭建控制器和视图?例如,对于我在 EF 4.2 代码优先中分配了 DbSet 的 70 多个类中的每一个类?或者每次更改庞大的数据模型时是否都必须重新搭建 1 到 100 个类?

我刚刚打算改用动态数据来实现此功能,但我想我又改变了主意。太多错误和性能问题。如何在 MVC 中实现动态数据的甜蜜?

我之前创建了一个递归对象模板,并使用代码优先模型上的属性来控制渲染。但这不一定是我想要的。只是一种一遍又一遍地快速搭建 70 多个类的控制器和视图的方法。然后通过 EF 迁移和一些语音命令软件,我也许可以在吊床上工作。

编辑:我在这里找到了这个 类似的帖子 。现在我必须了解 powershell 是什么?那买个吊床?

Does MVC 3 have a way to automatically scaffold controllers and views for my entire code first model? For example for each of 70+ classes that I have assigned a DbSet in EF 4.2 code first? Or do I have to re-scaffold between 1 and 100 classes every time I change my huge data model?

I just about switched over to using Dynamic Data for this functionality but I think I'm changing my mind again. Too many errors and performance issues. How can I achieve Dynamic Data sweetness in MVC?

I had created a recursive object template before and was using attributes on the code first model to control the rendering. That's not necessarily what I'm looking for though. Just a way to quickly scaffold controllers and views for 70+ classes over and over and over again. Then with EF migrations and some voice command software I can work in a hammock maybe..

EDIT: I found this similar post here. Now I have to learn what powershell is I guess? Then buy a hammock?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小耗子 2025-01-03 16:16:58

我使用反射来获取 DbContext 的 DbSet 中类型的 CSV 样式列表。然后在包管理器控制台中使用 NuGet 中的 MvcScaffolding 来遍历它们以及引用我现有上下文类型的脚手架控制器。

PM> $Types="WindowStyle", "WindowSize", "WindowPreset", "WindowGridColor",
"Window", "VinylSidingColor", "VinylShutterColor", "VinylFlowerBoxColor",
"TrimMaterial", "ThirdPartyService", "State", ....

然后

foreach($t in $Types) { Scaffold Controller -ControllerName $t -NoChildItems -DbContextType MyContext -Verbose }

我想在构建观点时我可能必须注意多元化问题。

I used reflection to get a CSV style list of the types in my DbContext's DbSets. Then used MvcScaffolding from NuGet in the Package Manager console to foreach through them and scaffold controllers referencing my existing context type.

PM> $Types="WindowStyle", "WindowSize", "WindowPreset", "WindowGridColor",
"Window", "VinylSidingColor", "VinylShutterColor", "VinylFlowerBoxColor",
"TrimMaterial", "ThirdPartyService", "State", ....

and then

foreach($t in $Types) { Scaffold Controller -ControllerName $t -NoChildItems -DbContextType MyContext -Verbose }

I think I might have to watch for pluralization issues when scaffolding the views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文