Entity Framework Exception: Invalid object name

前端 未结 6 723
故里飘歌
故里飘歌 2020-12-15 04:09

I am trying to create database using Code First approach. When I run the following code I am getting the following exception. Is there anything wrong in the fields that I de

6条回答
  •  不知归路
    2020-12-15 04:38

    I've just ran into the exact same issue - I'd already created my database on a development SQL box inside our network that needs SQL authentication.

    When I ran my app, no tables were created. I found this awesome but simple article about creating a Code First Database Initializer Strategy which first checks to see if the database exists and then runs a script against the database to create the tables.

    As stated in the article - pay attention that when such a strategy is deployed, whenever the application starts over, all the database tables will be recreated! This strategy should only run once.

    But you already knew that.

提交回复
热议问题