最佳实践 - 如何在 ServiceStack.OrmLite .NET 项目中扩展数据库?

Best Practice - How to extend the DB in a ServiceStack.OrmLite .NET project?

我最近接手了一个 .Net 项目,该项目通过 ServiceStack REST API 从 Microsoft SQL 数据库公开 DAOs。服务器运行在 IIS 7.5

AppHost.Configure 中,完整的数据库模式是这样创建的...

var dbFactory = new OrmLiteConnectionFactory(DI.DefaultConnectionString, SqlServerOrmLiteDialectProvider.Instance);
        using (var db = dbFactory.OpenDbConnection())
        {
            if (!db.TableExists(db.GetTableName<SomeSpecificDAO>())) //Create table if not exists
            {
                db.CreateTable<SomeSpecificDAO>();
                db.Insert(new SomeSpecificDAO { Data = 0, AnotherData = "", AnSoOne =  });
            }

        /// alot more tables follow....
        }

当我现在想扩展 DAO(例如,因此向 table 添加一个新列)时,我会在 Visual Studio 中执行此操作,测试它,如果它有效 我会通过实时测试服务器上的 Microsoft SQL Server Management Studio 远程添加该列,因为我不想丢失数据库中的任何数据。当只有一列要添加时,这不是很快,如果添加更多 tables/columns 或 f.e,它会非常麻烦。单元格的数据类型已更改。

在 Visual studio 和测试系统上更新数据库的最佳做法是什么?甚至可以有一个 "Code First approach" 我只扩展 DAO 然后更新数据库吗?

看看这个 existing thread in the ServiceStack Customer Forums,它解释了处理数据库架构更改的不同策略。