How to create a Not Null field with an index associated with Nhibernate Fluent

Asked

Viewed 27 times

0

I have a problem creating a field when using Fluent Nhibernate with SQL Server (C#):

I have this entity with some fields with primitive types and others are complex fields:

    public class OperationActivePermission : EntityBase<int>
    {
        public virtual int? BarCodeMinLength { get; set; }
        public virtual int? BarCodeMaxLength { get; set; }

        public virtual bool Active { get; set; }
        public virtual DateTime ActivationDate { get; set; }
        public virtual DateTime DeactivationDate { get; set; }

        public virtual Operation Operation { get; set; }
        public virtual PermissionType PermissionType{ get; set; }
        public virtual UserMobile ActivationUser { get; set; }
        public virtual UserMobile DeactivationUser { get; set; }
    }

Entitybase, help me create a common field for all entities Id, that is primary key.

Then I created an Override class to characterize some of these fields:

    public class OperationActivePermissionMappingOverride : IAutoMappingOverride<OperationActivePermission>
    {
        public void Override(AutoMapping<OperationActivePermission> mapping)
        {
            mapping.References(x => x.ActivationUser).Not.Nullable();
            mapping.References(x => x.Operation).Not.Nullable();
            mapping.References(x => x.PermissionType).Not.Nullable();

            mapping.Map(x => x.Active).Not.Nullable();
            mapping.Map(x => x.ActivationDate).Not.Nullable();

            mapping.References(x => x.Operation).Index("idx_Operation");
        }
    }

My problem is this: The field for which I created a single index is not characterized as Not Nullable...

Tabela no MS SQL Server

I don’t know that much about Nhibernate or Fluent and I can’t find the problem. I appreciate a tip ;)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.