I got a MySQL database which, on some tables, has an auto-incremented BigInt as PK. When I try to add a new object to the table I get an 'InvalidCastException' on SubmitChanges().
I know that that is the problem because for testing I removed the auto_increment from LinqConnect on that property and set the 'IsDbGenerated' property to false and filled the field with a random number and it worked. After I changed everything back again, I get the InvalidCastException again.
The field as it is declared in the autogenerated *.cs file:
Code: Select all
[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, CanBeNull = false, DbType = "BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", IsDbGenerated = true, IsPrimaryKey = true)]
public decimal ID
{
get
{
return this._ID;
}
set
{
if (this._ID != value)
{
this.OnIDChanging(value);
this.SendPropertyChanging();
this._ID = value;
this.SendPropertyChanged("ID");
this.OnIDChanged();
}
}
}
Got it fixed. Problem was that it was a decimal in .NET, after I changed it to System.UInt64 it worked.