If we do not specify EF Code First uses SQLEXPRESS instance in our machine to create the database from our POCO classes. Is there a way to change the default instance without giving a connection string(specifying with the databse)? I mean when i run my application for the first time i want EF Code First to create the database in my "." instance.
1 Answer
This will help you: http://blogs.msdn.com/b/adonet/archive/2012/01/12/ef-4-3-configuration-file-settings.aspx
In 4.3, you can use a constructor:
If you don’t set a default connection factory, Code First uses the SqlConnectionFactory, pointing to .\SQLEXPRESS. SqlConnectionFactory also has a constructor that allows you to override parts of the connection string. If you want to use a SQL Server instance other than .\SQLEXPRESS you can use this constructor to set the server.