When in Mono - Monodevelop (Tested on Mac OS X Mountain Lion)
In WebApp.Bootstrap.AppHost
uncomment Sqlite and comment SQL Server :
IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory ( ":memory:" , false , SqliteOrmLiteDialectProvider . Instance ) ;
this . CreateSqliteInMemoryTables ( dbFactory ) ;
// string connectionString = ConfigurationManager.ConnectionStrings["QcoachServiceStack"].ConnectionString;
// IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, false, SqlServerOrmLiteDialectProvider.Instance);
When in .NET - Visual Studio
In WebApp.Bootstrap.AppHost
uncomment SQL Server and comment Sqlite :
// IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance);
// this.CreateSqliteInMemoryTables(dbFactory);
string connectionString = ConfigurationManager . ConnectionStrings [ "ServiceStackTest" ] . ConnectionString ;
IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory ( connectionString , false , SqlServerOrmLiteDialectProvider . Instance ) ;
Creating SQL Server Express Db Tables for first time
Connection string in web.config
:
<connectionStrings >
<add name =" ServiceStackTest" providerName =" System.Data.SqlClient" connectionString =" Data Source=.\sqlexpress;Initial Catalog=test-servicestack;Integrated Security=true;MultipleActiveResultSets=True" />
</connectionStrings >
Go to SSMS and add new Database named test-servicestack
.
Add CreateSqliteInMemoryTables
below the dbFactory of SQL Server.
After first run make sure this line of code is commented, because it will always DROP Table and recreate it.
string connectionString = ConfigurationManager . ConnectionStrings [ "ServiceStackTest" ] . ConnectionString ;
IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory ( connectionString , false , SqlServerOrmLiteDialectProvider . Instance ) ;
this . CreateSqliteInMemoryTables ( dbFactory ) ;