I've run into a bit of a problem. In MySQL there seems to be a limit for how large varchar primary keys can be before they are converted to text. 255 seems fine but 256 throws a: 'Specified key was too long; max key length is 767 bytes'
If I try to reduce the key length by one it works good in new setups but when applying to a previous database it results in the following message:
'The migration of a primary key to a different type is not
supported. PrimaryKey column [KeyName] of table [DataStore] is modeled
as nvarchar(255). Database has varchar(256)'
I thought of adding another field, int or Guid to be the identity key in order to open up "KeyName" for change, which works but not for databases that already have data in the table since new keys are not created (even with autoinc).
Is there any way I can solve this to make the system to work with MySQL and in the same time handle all the sites already running the system?
The original defintion:
MapType(x =>
new
{ }).WithConcurencyControl(OptimisticConcurrencyControlStrategy.Changed).ToTable(
"DataStore"
);
HasProperty(x => x.KeyName).IsIdentity().ToColumn(
"KeyName"
).IsUnicode().IsNotNullable().WithVariableLength(256);