从 LINQ-TO-SQL DBML 文件生成表/视图架构

发布于 2024-08-05 00:21:52 字数 301 浏览 2 评论 0原文

我想要一个数据结构描述的单一来源。

有人问数据库中的DBML文件发生变化时是否可以刷新。我的做法虽然愚蠢但很常见;打开它,删除所有内容,然后再次拖放。 我听说有一些第三者在做这些把戏。

但我在想,有什么办法可以反转操作吗?

在hibernate中,有一种方法可以从XML数据结构构建目标DB的DDL。

DBML文件有可能包含重建数据库DDL的所有信息吗? (例如,拥有这些 VIEW SQL、存储过程代码的副本),并即时构建“创建脚本”(就像您在 SQL Server Enterprise Manager 中所做的那样)

I'd like to have a single source of the description of the data structure.

Some people are asking can the DBML file being refreshed when it is changed in the database. The way I do is stupid but common; open it, delete all, and drag-drop again.
I heard that there are some 3rd party do the tricks.

But I am thinking, any way to inverse the operation?

In hibernate, there is a way to build the DDL of the target DB from the XML data structure.

Is it possible that the DBML file will contain all information to rebuild the DDL of the database? (e.g. have a copy of those VIEW SQL, stored procedure codes), and build the "Create script" on the fly (like what you do in SQL Server Enterprise Manager)

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

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

发布评论

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

评论(1

在巴黎塔顶看东京樱花 2024-08-12 00:21:52

DBML 文件仅包含表、列、外键约束和主键。视图的存储方式与表相同,因此存储的唯一信息是视图的名称以及它返回的列(w/类型、可为空性等)。视图定义本身不被存储,因此无法从 dbml 文件中提取。

如果您使用 L2S 设计器和底层 DBML 文件进行数据建模,您将丢失:

  • 非 PK 索引/键
  • 视图定义
  • 存储过程定义
  • 函数定义
  • 别名类型
  • ...等等...

也就是说,如果您想生成 SQL -DBML 中的表定义、FK、PK 等的 DDL,我的 Visual Studio 插件可以为您做到这一点。 (它支持同步 db -> dbml 和 dbml -> sql-ddl -> db 您可以从以下位置下载它并获取试用许可证:
http://www.huagati.com/dbmltools/

The DBML file only contain tables, columns, foreign key constraints, and primary keys. Views are stored in the same way as tables, so the only information stored is the name of the view and what columns (w/ type, nullability etc) that it return. The view definition itself is not stored and therefore not possible to extract from the dbml file.

If you use the L2S designer and the underlying DBML file for data modelling you will lose:

  • non-PK indexes / keys
  • view definitions
  • stored proc definitions
  • function definitions
  • alias types
  • ...etc...

That said, if you want to generate the SQL-DDL for table defs, FKs, PKs etc from your DBML, my add-in for Visual Studio can do that for you. (It supports sync both ways db -> dbml, and dbml -> sql-ddl -> db You can download it and get a trial license from:
http://www.huagati.com/dbmltools/

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