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

查看:607
本文介绍了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.

因此​​,这是正确的方式去创造一个DBML文件中MVC项目使用,只需拖放整个表结构进入和去城里?如果没有,你怎么办呢?

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天全站免登陆