Increase field size varchar (existing in database) with Nhibernate

Asked

Viewed 54 times

1

Let’s say that this field with size 11 exists in the database, in several clients..

Map(x => x.CpfCnpj).Not.Nullable().Length(11);

And one day I need to increase it to . Length(14). Is there any way to configure for Nhibernate to do this automatically, or just via script in the database?

I imagine you have something here to set up, I just haven’t found it yet:

FluentConfiguration FConf = Fluently.Configure()
                .Database(configDB)
                .Mappings(c => c.FluentMappings.AddFromAssemblyOf<Map.UsuarioMap>())
                .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true));
  • i think only by changing straight into the bank. In fact it is the simplest and quickest solution to achieve what you want.

1 answer

0


Workable solution, use fluentmigration:

   public class PessoaMigration : Migration
   {
        public override void Down()
        {
        }

        public override void Up()
        {
            Alter.Column("cpfcnpj")
                .OnTable("Pessoa")
                .AsString(14);
        }
    }

Browser other questions tagged

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