1

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 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.