Can’t perfrorm Create, Update or Delete operations on Table(..) because it has no primary key

I stumbled upon this logical error after having published a new table in the EPiServer DXC environment and had it deployed to preparation and production. As you may know, you cannot publish changes to the prep and prod databases directly in DXC, due to which I was stranded with having non-functional code just after Friday’s last update window (DXC does not handle update / publish requests on the weekend.)

I simply forgot to add the Primary Key to my table schema. I added it to the integration database and was just about to send a new request to EPiServer managed services when I decided to try to change my .Net code instead. My code was something simple like this:

// Utilizing System.Data.Linq.Mapping

[Table(Name=”IATACode”)]
public class Kvp
{
[Column]
public string Code { get; set; }

[Column]
public string City { get; set; }
}

I rolled back the changes I did to the table (no primary key), but performed the following change:

[Column (IsPrimaryKey = true)]
public string Code { get; set; }

And it worked. Nice.

What was new to me is that the table column (ColumnAttribute, System.Data.Linq.Mapping.) does not need to be in sync with the .Net Column definition. Weekend saved. (I mostly work on weekends, too.)

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s