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

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

问题描述

如何将Linq更新为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:

a.在数据库资源管理器中刷新数据库架构(右键单击,刷新)
b.删除表格后保存设计器
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,可以在单个组件>代码工具下找到它.

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更新为SQL dbml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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