如何更新 Linq to SQL dbml 文件? [英] How do I update a Linq to SQL dbml file?

查看:35
本文介绍了如何更新 Linq to SQL dbml 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更新 Linq to SQL .dbml 文件?

How do I update a Linq to SQL .dbml file?

推荐答案

有三种方法可以保持模型同步.

There are three ways to keep the model in sync.

  1. 从设计器中删除修改后的表,然后将它们从数据库资源管理器拖回设计器图面.我发现,要使其可靠地工作,您必须:

  1. Delete the modified tables from the designer, and drag them back onto the designer surface from the Database Explorer. I have found that, for this to work reliably, you have to:

一个.在数据库资源管理器中刷新数据库架构(右键单击,刷新)
湾删除表后保存设计器
C.拖回表格后再次保存.

a. Refresh the database schema in the Database Explorer (right-click, refresh)
b. Save the designer after deleting the tables
c. Save again after dragging the tables back.

注意,但如果您修改了任何属性(例如,关闭关联的子属性),这显然会丢失这些修改       你必须重新制作它们.

Note though that if you have modified any properties (for instance, turning off the child property of an association), this will obviously lose those modifications — you'll have to make them again.

使用 SQLMetal 从您的数据库重新生成架构.我看过许多博客文章,这些文章显示 如何编写此脚本.

Use SQLMetal to regenerate the schema from your database. I have seen a number of blog posts that show how to script this.

直接在 DBML 的属性"窗格中进行更改.这适用于简单的更改,例如允许字段为空.

Make changes directly in the Properties pane of the DBML. This works for simple changes, like allowing nulls on a field.

Visual Studio 2015、2017 或 2019 中默认未安装 DBML 设计器.您必须关闭 VS,启动 VS 安装程序并修改您的安装.LINQ to SQL 工具是您必须安装的功能.对于 VS 2017/2019,您可以在 Individual Components > Code Tools 下找到它.

The DBML designer is not installed by default in Visual Studio 2015, 2017 or 2019. You will have to close VS, start the VS installer and modify your installation. The LINQ to SQL tools is the feature you must install. For VS 2017/2019, you can find it under Individual Components > Code Tools.

这篇关于如何更新 Linq to SQL dbml 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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