Varun Gupta
Varun Gupta

Reputation: 1457

Change Primary Key of .edmx

I have a .edmx file generated from a database having table "table1".

table1 has following attributes.

ID: Int (Primary Key)
Name: String
Tag: String
Description: String

In my edmx file, I want to change primary key from ID to (Name, Tag). How can I do that?

Upvotes: 0

Views: 1594

Answers (1)

Studly Geek
Studly Geek

Reputation: 11

In the .edmx file, CSDL section, look for a tag for the element you want to change:

<edmx:ConceptualModels>
      <Schema Namespace="DatabaseFirst.BloggingModel" ... >
        <EntityType Name="Blog">
          <Key>
            <PropertyRef Name="BlogId" />
          </Key>
          <Property Name="BlogId" Type="InT32" ...  />

Change the Name attribute in the PropertyRef and Property tags to your new desired primary key name.

Upvotes: 1

Related Questions