Shikha
Shikha

Reputation: 339

How should I add Column Level CHARSET using Fluent NHibernate?

I am using Fluent Nhibernate with MySQL Configuration to expose schema. Below is my database entity with entity mapping.

public class MyEntity 
{
    public MyEntity() { }
    public virtual int ID {get;set;}
    public virtual string FormalName { get; set; }
}

public class MyEntityMap : ClassMap<MyEntity>
{
    public MyEntityMap() 
    {
        Table("MyEntity");
        LazyLoad();
        Id(x => x.ID).GeneratedBy.Assigned().Column("ID");
        Map(x => x.FormalName).Column("FormalName").Length(200); // In Script must be FormalName VARCHAR(200) CHARSET Latin1
    }

Upvotes: 0

Views: 138

Answers (1)

amol t
amol t

Reputation: 11

Simplest way as I think would be to add CustomSQLType in Map and add CHARSET within it.

eg.

Your code should be :

Map(x => x.FormalName).Column("FormalName").CustomSqlType("varchar(200) charset latin1").Length(200); // In Script must be FormalName VARCHAR(200) CHARSET Latin1

Notice the CustomSqlType in above code.

Upvotes: 1

Related Questions