开发者

Unique key column order in fluent nhibernate

I try to create unique index with fluent nhibernate. But when i use the following classes tables are created like :

Person Table:
Id
Name

PersonStatistic Table:
Id
Date
Count
Person_Id

Because of this structure when i create the unique key, column order look like "Date - Person_Id". But i want to column order in key like "Person_Id - Date"

Entity and map classes like below.

Entity classes :

public class Person()
{
    public virtual Guid Id { get; set; }
    public virtual string Name { get; set; }
}

public class PersonStatistic()
{
    public virtual Guid Id { get; set; }
    public virtual DateTime Date { get; set; }
    public virtual long? Count { get; set; }
    public virtual Person Person { get; set; }
}

Map classes :

public PersonMap()
{
    Id(x => x.Id).GeneratedBy.GuidComb();
    Map(x => x.Name).Not.Nullable().Length(50);
}

public PersonStatisticMap()
{        
    Id(x => x.Id).GeneratedBy.GuidComb();
    Map(x => x.Date).Not.Nullable().UniqueKey("UK_Person_Date");
    Map(x => x.Count).Nullable();

    References(x => x.Person)
        .Not.Nullable()
        .UniqueKey("UK_Person_Date");
}

Something is wrong in my classes or mapping or another trick to set column o开发者_运维问答rder in key?


Try putting the References call before the Map one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜