ASP.Net MVC:dbml 文件的最佳实践 [英] ASP.Net MVC: Best Practices for dbml files

查看:26
本文介绍了ASP.Net MVC:dbml 文件的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能只是一个是或否类型的问题,但无论如何...

This may just be a yes or no type of question but here goes anyway...

从我见过的使用 mvc 的所有(以及大多数)示例来看,创建 dbml 文件的方法似乎只是将数据库的整个架构放入其中,并让它自动生成所有 linq 到sql 善良.看来您只需要其中一个(因为您不能在同一个项目中的单独 dbml 文件中使用重复的表)但出于某种原因,似乎有更好的方法来做到这一点……尤其是在处理具有相当数量表的大型项目.

From all (well most) of the examples that I've seen for using mvc, it appears that method for creating the dbml file is just drop the entire schema of the database into it and let it autogenerate all of the linq to sql goodness. It appears that you just need one of these (as you can't have duplicate tables in separate dbml files in the same project) but for some reason it would seem like there's a better way to do this...especially when dealing with a large project that has a fair number of tables.

那么这是创建要在 mvc 项目中使用的 dbml 文件的正确方法,只需将整个表结构放入并前往镇上即可?如果没有,你怎么做?

So is this the proper way to go about creating a dbml file to use in a mvc project, just drop the entire table structure into and go to town? If not, how do you do it?

推荐答案

如果架构很大,我想我会完全依赖 SQLMetal 脚本来生成我的 *.dbml 和支持类.通过这种方式,您可以在数据库更新时重新生成整个数据模型.否则,如果表、视图等在数据库中更新,您不必删除,然后将该表重新拖放到可视化 *.dbml 文件中.

If the schema was large, I think i would be relying fully on a SQLMetal script to generate my *.dbml and backing classes. This way you can just regenerate your entire data model whenever your database gets updated. Otherwise, if a table, view, etc, gets updated in the database you don't have to delete and then re drag-and-drop that table into your visual *.dbml file.

实际上,我不是 SQLMetal 的专家,但我认为您甚至可以使用它来生成 Linq-toSql 所需的一切,甚至不需要/生成 *.dbml 文件.

Actually, I am not expert with SQLMetal, but I think you can even use it it to generate everything you need for Linq-toSql and not even require/generate a *.dbml file.

这篇关于ASP.Net MVC:dbml 文件的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆