问题描述
我目前正在学习 C# 和 LINQ.我有很多关于他们的问题.基本上,我需要一个循序渐进的教程.
I am currently learning C# and LINQ. I have lots of questions about them. Basically, I need a step by step tutorial.
我想
dbml
文件是数据库的配置文件.如果我双击dbml
文件,VS 将在设计图中打开它.我可以在这里创建/删除/修改表吗?我可以使用add new item
添加LINQ to SQL Classes
以获得dbml
文件?
I suppose the
dbml
file is the configuration file of the database. If I double click thedbml
file VS will open it in a design diagram. Can I create/delete/modify tables here? I can useadd new item
to add theLINQ to SQL Classes
to get adbml
file?
接下来是什么?在数据库中生成表?生成 SQL 脚本?生成cs文件?什么时候?怎么样?
What's next? Generate tables in database? Generate SQL script? Generate cs files? When? How?
推荐答案
DBML 文件与数据库服务器完全无关.这完全是客户端的事情.它本质上是关于数据库中的表以及如何将它们映射到 .NET 对象的一组信息.
The DBML file is not related to the database server at all. It's a completely client side thing. It's essentially a set of information about your tables in the database and how you're going to map them to .NET objects.
当然,您可以从数据库中拖出一个表并让 Visual Studio 自动为您推断一些信息,但更改文件不会影响数据库.您也可以在没有任何数据库的情况下从头开始创建 DBML 文件.
Of course, you can drag a table from a database and have Visual Studio infer some information for you automatically, but changing the file will not affect the database. You can create a DBML file from scratch without any database too.
在内部,DBML 文件只是一个 XML 文件,它由 Visual Studio 提供给自定义工具,并从中生成表示数据库的 LINQ 对象模型的 .cs
文件.
Internally, the DBML file is simply an XML file that's fed into a custom tool by Visual Studio and generates .cs
files representing the LINQ object model for your database from it.
这篇关于C# dbml 文件来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!