-4

I am just try to creating Database using entity Framework5.0 code first Approach In Mvc web Application when i execute code it execute fine but not creating database.if i send input values from views then Database is created??? I Want to know whats the mechanism behind this entity frame work code Approach Can any one Help to find out the mechanism of entity frame work.

1

2 Answers 2

0

How do know it didn't create the database? If everything works fine, I mean no errors, the database should be created already.

My guess is you didn't specify the connection string which caused the database created in SQL Express.

3
  • first time when i execute the code then code do not show any error and execute fine and show the signup view when i finish the execution and check it does not make database. if i run again and provide the values in signup form then it create database. why this is odd behviour? it should create database when i execute and browse the page Commented Jun 13, 2013 at 9:13
  • Em providing conection String it works fine but its odd behaviour is distrubing me. Commented Jun 13, 2013 at 9:14
  • It will create database when you first access the database. I'm sure the signup httpget action doesn't access the database.
    – Jason Li
    Commented Jun 13, 2013 at 9:14
0

I guess you are using the wrong database creation strategy

3
  • What kind of Wrong Strategy??? i have two basic classes of userLogin ,and User sign up class and anther class is UserContext class that is inherit from DbContext class and to create a databse table i use 'public DbSet<Category> Categories { get; set; } public DbSet<Product> Products { get; set; }' method for constr 'public OnlineShopContext() :base("Name=Constr3") { }' Commented Jun 13, 2013 at 8:53
  • And constr is ' <connectionStrings> <clear /> <add name="Constr3" connectionString="Data Source=.;Initial Catalog=EShop1;Integrated Security=true" providerName="System.Data.SqlClient" /> </connectionStrings> ' Commented Jun 13, 2013 at 8:56
  • I'm sorry, but what database creation strategies for code first are is something google can easily answer.
    – b_meyer
    Commented Jun 13, 2013 at 8:58

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.