MvcScaffolding - 它支持模型优先吗?

发布于 2024-10-21 02:26:10 字数 148 浏览 2 评论 0原文

我已经尝试过 MvcScaffolding 项目 - 非常好顺便说一句;但是,有谁知道它是否支持模型优先设计方案(例如 EF4 数据模型 -> 从数据库生成)?

如果它确实支持模型优先场景,您是否知道任何描述模型优先设计场景的链接?

谢谢...

I've toyed around with the MvcScaffolding project - very nice BTW; however, does anyone know if it supports Model First design scenarios (e.g. EF4 Data Model -> Generate from Database)?

If it does in-fact support Model First scenarios, do you know of any links describing a Model First design scenario?

Thanks...

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

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

发布评论

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

评论(6

黯然#的苍凉 2024-10-28 02:26:10

MvcScaffolding 就其脚手架适用的场景而言非常灵活。但是,要支持除默认代码优先之外的任何内容,您可能需要稍微调整输出。 MvcScaffolding 本身没有任何约束,而是您首先使用模型,代码优先或其他。你所要做的就是将它指向一个公共类,它就会搭建它的脚手架。

但是,MvcScaffolding 附带的文本模板旨在生成与 EF 4.1 代码优先类型交互的控制器代码,因此需要对生成的控制器代码进行一些调整以支持模型优先场景。

我刚刚使用模型优先方法完成了整个 MvcScaffolding 实现。就我而言,我不想使用仍处于预发布状态的实体框架 4.1。此外,我不想手动编写实体模型所需的所有类型。我没有在生成完成后调整输出,而是编辑了模板以完全按照我想要的方式生成代码。最终结果是我能够针对模型优先实体框架 4.0 实现生成、编译和运行。

如果您不害怕稍微调整一下,MvcScaffolding 并不挑剔它将为哪些场景构建脚手架代码。使用实体框架 4.1 中实现的代码优先场景肯定更容易,但只需做一些工作,您就可以让它支持模型优先场景。

MvcScaffolding is pretty flexible in terms of what scenarios it's scaffolding will work for. However to support anything other than the default which is code first you may have to tweak the output a little. MvcScaffolding itself doesn't have any constraints around rather you're using model first, code first or whatever. All you have to do is point it to a public class and it will scaffold it.

However, the text templates that ship with MvcScaffolding are designed to generate controller code that interfaces with EF 4.1 code first types, so there would be some tweaking of the generated controller code necessary to support a model first scenario.

I just completed an entire MvcScaffolding implementation using a model first approach. In my case I didn't want to use entity framework 4.1 which is still pre-release. Additionally, I didn't want to hand code all of the types required by my entity model. Rather than tweak the output after the generation was complete, I edited the templates to generate the code exactly the way I wanted it. The end result was I was able to generate, compile and run against a model first entity framework 4.0 implementation.

MvcScaffolding isn't picky about what scenarios it will scaffold code for if you're not afraid to tweak it a little. It is definitely easier to work with code first scenarios as implemented in entity framework 4.1 but with a little work you can get it to support model first scenarios as well.

荆棘i 2024-10-28 02:26:10

我目前也在探索这个问题。 的示例

这是使用 Northwind http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx

看起来也像那里是一个陷阱

http://mvcscaffolding.codeplex.com/discussions/247163

我的一些笔记和屏幕截图在这里:

http://www.programgood.net/2011/03/11/ EntityFramework.aspx

寒尘 2024-10-28 02:26:10

请访问 http://www.devart.com/linqconnect/ 查看 LinqConnect。我还没有使用过它,但过去一周我一直在研究它,我认为它听起来很令人兴奋。

Check out LinqConnect at http://www.devart.com/linqconnect/. I haven't used it yet, but I've been researching it over the past week and I think it sounds exciting.

原野 2024-10-28 02:26:10

使用 Model First 和 Entity Framework 4.1 构建 MVC 3 应用

Julie Lerman 向我们展示了如何在 MSDN 上手动完成

我的建议:在 Models 文件夹下生成强类型实体类并创建真实数据库后,使用 mvcscaffolding:

PM>scaffold Controller MyEntityClass

Building an MVC 3 App with Model First and Entity Framework 4.1

Julie Lerman show us how to do it by hand on MSDN

My suggestion: after strongly typed entity classes have been generated under Models folder and real database has been created, use mvcscaffolding:

PM>scaffold Controller MyEntityClass

只为一人 2024-10-28 02:26:10

是的,确实如此。而且也很好。

即我成功地将它与新的 DbContext POCO T4 模板一起使用
例如

  1. 添加您的 edmx =>从数据库更新
  2. 右键单击​​ edmx 设计器
  3. 选择“添加代码生成项”
  4. 选择 ADO.NET DbContext Generator

这将删除:ObjectContext 派生的 .designer.cs 代码,并替换为 DbContext .tt 文件。

然后脚手架走开! (记住将 -DbContextType 传递到您的脚手架命令中)

Yes it does. And very well too.

i.e. I am using it successfully with the new DbContext POCO T4 templates
e.g.

  1. Add your edmx => update from database
  2. Right click the edmx designer
  3. Select "add code generation item"
  4. Select ADO.NET DbContext Generator

This will remove the : ObjectContext derived .designer.cs code, and replace with the DbContext .tt files.

Then scaffold away ! (remembering to pass the -DbContextType into your scaffolding cmds)

笙痞 2024-10-28 02:26:10

我已经提出了针对数据库第一个场景执行此操作的步骤。请参阅 http: //weblogs.asp.net/paullitwin/archive/2011/08/11/use-mvc-scaffolding-in-database-first-mode.aspx

I have come up with the steps to do this for a database first scenario. See http://weblogs.asp.net/paullitwin/archive/2011/08/11/use-mvc-scaffolding-in-database-first-mode.aspx

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