How to update varchar column lengths in Nhibernate?
I'm using Nhibernat开发者_开发技巧e and Fluent Nhibernate.
I fell into the trap I think a lot of new users fall for, and ended up with all my varchar columns at 255 chars. For politic reasons far too boring to go into, there was immediately data in these fields that I'm not supposed too delete (boo) so I need to update the column lengths without dropping and re-creating tables.
However if I apply a convention for string length to the Fluent configuration, and use the NHibernate UpdateSchema method, only new tables seem to get the new varchar length. Is this correct and is there a way to apply this to the existing tables??
you don't necessarily need nHibernate for that..
you didn't mention what the underlying DB instance is, but I'm sure it has options for updating column properties. I think it's the simplest solution.
UpdateSchema only applies non-destructive updates. It is not meant as a migration utility, but for rapid changes to models/database tables during development. For more information, see my answer to NHibernate, ORM : how is refactoring handled? existing data?.
精彩评论