How to auto Alter Table if new version added new columns

Is it serviceStack have function to auto Alter Table if new version added new columns?

No, but I just answered a question earlier today on how I handle schema migrations which may be helpful.

It took a bit of finessing, but we created our own public static bool AlterTable<T>(this IDbConnection db) where T : new() extension method and dynamically add new columns as per the new poco.

We noticed that [Default] on properties isn’t necessarily handled in this context when auto generating AlterSQL with the dialect provider, so we even force a default value in the field definition to allow adding non-nullable columns to the poco. For drastic model changes we implemented custom class attributes with model versions and alter vs drop/create instructions.

Sounds crazy, but works like a charm and super helpful. Now when you add new properties to existing classes, or new classes, the db backend automagically adapts to 99% of the cases.

The ServiceStack OrmLite framework makes it possible to adapt to your custom needs quite reasonably.

1 Like