简体   繁体   English

EF .edmx是否在数据库外键标识符上创建抽象层

[英]Does EF .edmx create an abstract layer over the DB Foreign keys identifiers

I am working on an asp.net mvc web application , and I use EF to map an exsiting DB and create .edmx file. 我正在使用asp.net mvc Web应用程序,并且使用EF映射现有数据库并创建.edmx文件。

But I am not sure about something, now inside my Development server I have the following relation, named:- 但是我不确定什么,现在在开发服务器中,我具有以下关系,名为:-

FK_SecurityRoleGroups_Groups FK_SecurityRoleGroups_Groups

在此处输入图片说明

But inside my staging server I got this relation named FK_Table_Table instead of FK_SecurityRoleGroups_Groups, but with the same parent and child tables and columns. 但是在我的登台服务器内部,我得到了名为FK_Table_Table而不是FK_SecurityRoleGroups_Groups的关系,但是具有相同的父子表和列。 So now if I deploy my asp.net mvc web application from my Dev to testing server ,, will this cause any problem ? 因此,现在如果我将Dev.asp.net mvc Web应用程序从我的Dev部署到测试服务器,这会引起任何问题吗? or the FK identifier does not matter inside the .edmx file and what really matters is the associated Parent and child tables and columns ? 还是FK标识符在.edmx文件内部无所谓,并且关联的父表和子表和列真正重要的是什么? Regards 问候

If you build the edmx from the database the relationships get converted into what are called "Associations". 如果从数据库构建edmx,则关系将转换为所谓的“关联”。 Associations by default are named the same as the relationship. 默认情况下,关联与关系的名称相同。

The name itself isn't of technical importance and the association definition contains all the details of how the model should act and how it relates to the database. 名称本身并不具有技术重要性,并且关联定义包含有关模型应如何操作以及如何与数据库关联的所有详细信息。 You can redefine your association names to a new standard, but it might be confusing if you're looking to match them up with the database. 您可以将关联名称重新定义为新的标准,但是如果您希望将它们与数据库进行匹配,可能会造成混淆。 If you open up the edmx in notepad you can see how your associations are defined. 如果在记事本中打开edmx,则可以看到如何定义关联。

<Association Name="FK_Address_User">
    <End Role="User" Type="Self.User" Multiplicity="1" />
    <End Role="Address" Type="Self.Address" Multiplicity="*" />
    <ReferentialConstraint>
        <Principal Role="User">
            <PropertyRef Name="UserID" />
        </Principal>
        <Dependent Role="Address">
            <PropertyRef Name="UserID" />
        </Dependent>
    </ReferentialConstraint>
</Association>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM