Entity Framework Code First Doesn't Generate Database -


i created db context class , added connection string in web.config file instructed in scott guthrie's code first development entity framework 4. running test method. received several database errors running tests, when cleaned classes test succeeded, still had no database in app_data folder.

i added database.createifnotexists() dbcontext constructor, still no sdf file. know doing wrong?

for database automatically created, connection string name has named dbcontext subclass name (with namespace).

eg. db class this:

namespace mynamespace {     public class foodb : dbcontext     {             public dbset<xxx> abc{ get; set; }     } } 

your connection string should so:

  <connectionstrings>     <add name="mynamespace.foodb" connectionstring="data source=|datadirectory|mynamespace.foodb.sdf" providername="system.data.sqlserverce.4.0"/>   </connectionstrings> 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -