Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server In Memory Equivalent

My team has recently decided to move from EF to Dapper. As such we are moving a lot of the logic that was done in EF into Stored Procedures as part of our SQL Server DB. This means that a lot of the Unit Tests that we have for EF are now Integration Level tests as they involve the DB. I am looking for a way to run these tests using an In-Memory DB so I don't have to stand up a DB externally as part of the tests. I looked into SQLite but without the SP support, it would not be a fair comparison. Are there any other In-Memory DBs that would be similar to SQL Server that can be used for testing?

like image 837
165plo Avatar asked May 21 '18 15:05

165plo


1 Answers

You should be able to use the local version of SQL Server, named LocalDB, that doesn't require SQL Server to be installed as a Service...just the engine is needed:

https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-2016-express-localdb?view=sql-server-2017

The engine will be start as soon as you'll connect to a database, with a connection string that references the LocalDB engine, and also specifies the .mdf file you want to attach:

Server=(LocalDB)\MSSQLLocalDB; Integrated Security=true ;AttachDbFileName=D:\Data\MyDB1.mdf

like image 99
mauridb Avatar answered Sep 26 '22 17:09

mauridb