I am using the following code to add columns to a table (Server Management Objects library):
Column newColumn = new Column(tbl, name, DataType.Bit);
newColumn.Nullable = false;
newColumn.DefaultConstraint.Text = "0";
This works just fine for a while, but without fail, I am eventually no longer able to add columns. I get the error, "Alter failed for Table 'dbo.myTable'." (The InnerException.Message is "An exception occurred while executing a Transact-SQL statement or batch.")
I'm having a devil of a time trying to pinpoint the source of this problem. It might happen after I've actually edited some of the cells in the table, but I'm not sure.
Note that column rename and remove operations continue to work with no apparent problems. It's just adding columns that fails.
I'm hoping that someone out there with experience with this exception can help me out.