Control foreign key data type in Fluent NHibernate mapping -
i have fluent nhibernate configuration interacting 2 different schemas - new database being generated fnh, , legacy database. i'm using automapping overrides. 1 of tables in new db has foreign key column refers pk in legacy db. pk in question in legacy database of type char(10)
. can't seem find way declare fk column in new database should of same type - defaulting nvarchar(255)
i can manually change type of column in generated db after has been built, prefer build way expect begin with.
here relevant code snippets (which have been simplified)
public class salesorder { public virtual int id { get; set; } public virtual accountingsalesorder accountingsalesorder { get; set; } public class salesordermappingoverride : iautomappingoverride<salesorder> { public void override(automapping<salesorder> m) { m.references(x => x.accountingsalesorder).column("csono") // #### use 'customsqltype("char(10)")' here, // no such method exists ; } } } public class accountingsalesorder { public virtual string salesordernumber { get; set; } public virtual char revisionnumber { get; set; } } public class accountingsalesorderoverride : iautomappingoverride<accountingsalesorder> { public void override(automapping<accountingsalesorder> m) { m.schemaaction.none(); m.schema(persistenceinfo.accountingschema); m.table("sosord"); m.id(x => x.salesordernumber) .column("csono") .customtype<paddedstringl10usertype>() // #### declaring 'customsqltype("char(10)")' here not // change result ; m.map(x => x.revisionnumber).column("crevision"); } }
Comments
Post a Comment