Updating Columns with the rowguidcol property is not allowed.

by JasonRShaver 3. October 2007 16:39

 When using .netTiers (2.0, 2.1, or 2.2), on a database that has replication enabled, the following is required to prevent the "Updating Columns with the rowguidcol property is not allowed." exception. 

I found that the default behavior for updating a entity using SQL will try to update the RowGuid colomns, causing bugs for those of us using replication.  I found a fix in part of an email by Taylor Durden (http://community.codesmithtools.com/forums/thread/23074.aspx) that goes like this:

 Add this to the TemplateLib\CommonSqlCode.cs

/// <summary>
        /// Check if a column is a rowguid column for replication
        /// </summary>
        /// <param name="column">DB table column to be checked</param>
        /// <returns>Identity?</returns>
        public bool IsRowGuidColumn(ColumnSchema column)
        {
            if (column.ExtendedProperties["CS_IsRowGuidCol"] != null)
                return (bool)column.ExtendedProperties["CS_IsRowGuidCol"].Value;

            return false;
        }

and change this block in code around line 84 in \DataAccessLayer.SqlClient\StoredProceduresXml.cst

 foreach (ColumnSchema column in cols)
  {
   if ( ! IsIdentityColumn(column) && ! IsComputed(column) && ! IsRowGuidColumn(column) )
    colsUpdatable.Add(column);
    
   if (column.NativeType.ToLower() == "timestamp")
    RowVersion = column;
  }

 And this fixed this issue for me.  I wanted to break this issue out into a seperate thread then Mr. Durden issue, but the credit belongs with him.

 Jason R. Shaver 

 

Tags:

Blog

About the author

I am a software developer working for Microsoft in Redmond, WA.  In addition, my wife and I own TTXOnline, what is likely the 3rd largest table tennis store in the US.

Month List

Page List