We have an ASP.NET MVC Visual Studio 2012 project using Entity Framework 5.
There are several unit tests that are database dependent. Setting up the app.config file in a test project to use a central SQL Server database is fine.
However, it would be much better to use LocalDb so that each developer has their own database when running the tests. Especially since we would like the tests to be run at DropCreateDatabaseAlways at startup.
However, I cannot get this installation to work. If I try this in app.config:
<add name="TestDb" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=unittestdb; Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\unittestdb.mdf" providerName="System.Data.SqlClient" />
I get:
System.Data.SqlClient.SqlException: A file activation error occurred. The physical file name '\ unittestdb.mdf' may be incorrect. diagnose and fix additional errors, and repeat the operation. CREATE a database crash. Some file names cannot be created. Check for errors.
It looks like he wants the mdf file to already exist, which seems strange as he is trying to create a database. Creating the mdf file manually does not change the error message.
unit-testing entity-framework-5 visual-studio-2012 mstest localdb
Klas Mellbourn Sep 03 '12 at 8:38 2012-09-03 08:38
source share