# LinqToSQL:Alternative to mocking the Db

One of the really nice things about LinqToSQL is how simple it makes it to produce a new database. It fact it’s so easy you can produce a real DB with less effort than a Mock’d one.

I’m sure this has to be bad in some way, but I’ve no idea what that is yet. I’ll need to try it out on a decent environment with a Build Server (like at home).

public const string UnitTestConnection = “Data Source=.;Initial Catalog=UnitTest;Integrated Security=True”;

MyDataContext context = new MyDataContext(UnitTestConnection);
if (context.DatabaseExists())
{
context.DeleteDatabase();
}
context.CreateDatabase();
context.SubmitChanges();