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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With