Click here to Skip to main content
16,018,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to Entity Framework. I am using Code Firs. here my question is
when we using code first in EF when we give dbset in context it automatically generates database in sqlexpress or not?

or we have to give connection string in app.config. i am so much confused.

please help me

thank you.
Posted

1 solution

Specify where the database lives using the web.config file connection settings. make sure that the Context Name is your Connection String Name as below:
XML
<connectionstrings>
        <add name="YourContextName"
         connectionString="Server=aaaServer;Database=aaaDB;Uid=aaa;Password=aaa; " 
         providerName="System.Data.SqlClient"/>
</connectionstrings>
 
Share this answer
 
v2
Comments
sreekanthv12 14-Sep-12 12:18pm    
u mean it will create database automatically when we give connection string in app.config file.
ShotDriller 14-Sep-12 12:24pm    
Entity Framework Code First allows you to create data model classes prior to creating a database. When you run the application for the first time, a database is created for you on the fly based on the classes you created. Database initializers allow you to decide a strategy of database creation and seed data generation. Code First provides its own set of database initializer classes and also allows you to create your own.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900