【发布时间】:2012-11-20 01:27:25
【问题描述】:
sqlmetal 生成的关联名称一直是令人沮丧的根源。有时关联只是简单地去掉“Id”结尾的列名,有时它会根据外键约束名称生成关联名称。
我根本无法弄清楚它使用什么步骤来生成这些名称,而最近的架构更改又一次彻底改变了关联名称,所以我想了解一下。
我有两个表,它们以某种链的形式相互引用。像这样的:
class In
{
int Id;
EntityRef<Out> Yields; // YieldsId => FK_Out_Source
EntitySet<Out> In_Source; // FK_In_Source
}
class Out
{
int Id;
EntityRef<In> Yields; // YieldsId => FK_In_Source
EntitySet<In> Out_Source; // FK_Out_Source
}
这些是架构更改之前的类,其中 In 和 Out 表之间有一个额外的 FK 字段。删除该字段后,sqlmetal 现在会生成以下内容:
class In
{
int Id;
EntityRef<Out> Yields; // YieldsId => FK_Out_Source
EntitySet<Out> Out; // FK_In_Source
}
class Out
{
int Id;
EntityRef<In> In; // YieldsId => FK_In_Source
EntitySet<In> Out_Source; // FK_Out_Source
}
之前的类应该是完全对称的,但现在生成的类是完全不对称的。谁能解释一下?
【问题讨论】:
标签: linq-to-sql sqlmetal