Entity Framework 5 code-first not creating database

后端 未结 4 1538
星月不相逢
星月不相逢 2020-12-25 13:33

I\'m trying to create a new database using the code first concept of Entity Framework. However when running the code the database isn\'t created (using the DropCreateD

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-25 13:52

    So First Remove the Db Name from the constructor parameter on context class and provide Db_name on the connection string and then try to rebuild your solution and run the application it will create Database for you application.

    For Example :

    I am not passing the Db-Name on constructor parameter

    public EmployeeContext()
                : base()
            {
                Database.SetInitializer(new DropCreateDatabaseIfModelChanges());
            }
    

    and on the Connection string I am passing the Db-name like below.

        
       
    

提交回复
热议问题