user42
user42

Reputation: 347

How to set a new database for Entity Framework Code First project

I have a Code First Entity Framework project. It utilizes my local ./SQLEXPRESS instance for the database connection.

I need to move my database to a production server. What do I need to do to point Entity Framework to a different SQL Server instance and a different database?

Upvotes: 4

Views: 725

Answers (1)

devdigital
devdigital

Reputation: 34349

By convention Code First will look for a connection string in your configuration file with the same name as your context class (the class deriving from DbContext).

If you wish to override this, then you can pass in the connection string name (or connection string) to the DbContext constructor. See here for more information.

Upvotes: 5

Related Questions