How to change data type of [title_] of table [sf_meta_fields] from varchar to nvarchar
Hi guys.
I'm using Sitefinity for Vietnamese so I need to use Unicode in name of custom filed but Sitefinity cannot store it in database, can anyone help me?
Thanks so much.
Hello Thanh,
The column data type defined by default in the database can`t be changed and even if you do it will always revert back to the original data type. We only support one way synchronization with the database schema, custom changes of fields directly into the database are not preserved and Sitefintiy always tries to migrate the db schema to be up to date with the mappings defined in our code. When you rebuild your project - sitefinity performs an upgrade - because your new build number differs from the last schema version records kept in the databse.
During the upgrade we make sure the db schema (including column sizes) is up to date with the coded mappings of each persistent class.
What you need to do is use the MetadataMapping attribute if you want to specify whether type of given db column is VARCHAR or NVARCHAR. In your case you will need to pass two parameters to the MetadataMapping constructor -> bool isUnicode(e.g. whether is NVARCHAR) and bool isLong(e.g. whether is MAX).
[DataMember]
[MetadataMapping(true, true)]
public virtual Lstring WhatIsInTheBox
get
if (this.whatIsInTheBox == null)
this.whatIsInTheBox = this.GetString("WhatIsInTheBox");
return this.whatIsInTheBox;
set
this.whatIsInTheBox = value;
this.SetString("WhatIsInTheBox", this.whatIsInTheBox);