0

I have an existing and live database, it has about 100 tables.

For my application, I'm only using maybe 5 of those tables.

The database DOES NOT have relationships set up.

Is there a way to create those relationships in my .dbml file after dragging the tables in?

Also, if this is possible, does it update the existing database? Because I don't want to do that.

4

1 回答 1

3

您可以在设计表面上创建关系,是的。右键单击设计图面背景上的任意位置,然后从菜单中选择“添加 -> 关联”。在出现的对话框中,您可以选择父对象和子对象以及连接它们的属性。

我不相信这会更新数据库,不。在这方面,Linq to Sql 不像实体框架那样双向。当然,您需要对此进行测试以确保。此外,我不确定这是否会导致表达式树针对数据库构建错误的 SQL。不应该,因为即使没有实际的外键,这些连接仍然可以工作。但是,再一次(和所有事情一样),你会想要测试它。

于 2013-09-13T19:32:16.570 回答