2

I am new with Asp.Net and have issue with setting length for one property of My entity.

So this is my Entity:

public class AccountData : Entity
{
    public virtual Account Account { get; set; }

    public virtual string Key { get; set; }

    public virtual string Value { get; set; }

    public virtual string Properties { get; set; }
}

What I am trying is to set property "Key" to "Varchar(250)", because currently it set's it to Varchar(100):

public class AccountMetadataOverrides : IAutoMappingOverride<AccountData>
{
    public void Override(AutoMapping<AccountData> mapping)
    {
        mapping.References<Account>(k => k.Account, "AccountId").Nullable().Cascade.None();

        mapping.Map(x => x.Key).Column("`Key`").Not.Nullable();
        mapping.Map(x => x.Value).Column("`Value`");
        mapping.Map(x => x.Value).Length(1000);

        //Mapping length which is causing the issue
        mapping.Map(x => x.Key).Length(250);
    }
}

So without line:

 mapping.Map(x => x.Key).Length(250);

It's setting property Key to Varchar(100), but with this line it doesn't set this property at all in the database (it doesn't create column for it).

Can please anyone help me with this.

carpics
  • 2,272
  • 4
  • 28
  • 56

0 Answers0