Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify database name in Code First?

How do I tell EF what to name the database and where to put it?

If there is no connection string in the Web.Config, it tries to put it in the local SQLEXPRESS Server, but I want to put it out on a known SQL Server and name it what I want. Any suggestions?

like image 433
Sam Avatar asked Mar 18 '11 00:03

Sam


People also ask

How do I know if code first or database first?

In code first approach we will first create entity classes with properties defined in it. Entity framework will create the database and tables based on the entity classes defined. So database is generated from the code. When the dot net code is run database will get created.

What is code first from database?

Code-First is mainly useful in Domain Driven Design. In the Code-First approach, you focus on the domain of your application and start creating classes for your domain entity rather than design your database first and then create the classes which match your database design.


1 Answers

Create a connection string in the app.config/web.config with the same name as the context and the EF will use that DB.

like image 108
amit_g Avatar answered Sep 18 '22 14:09

amit_g