var options = new DbContextOptionsBuilderAt first when writing tests I was utilizing a magic string as in the example above. I came back to some unit test where I'd used unique names such as "test1", "test2" etc. After deleting a test and seeing my magic strings get out of sequence, it became apparent that this was going to be a maintainability nightmare. Hmmm, did I use "test6" yet?
() .UseInMemoryDatabase(databaseName: "Unique_db_name_here") .Options;
Unit tests methods already have unique names, so why not use the test name? With magic strings this approach would be terrible, but with the C# 6.0 nameof operator this approach works well.
This keeps the in memory names unique and keeps refactoring simple.