How to re-create database for Entity Framework?

后端 未结 7 1202
野趣味
野趣味 2020-11-30 16:18

I have got into a bad state with my ASP.Net MVC 5 project, using Code-First Entity Framework. I don\'t care about losing data, I just want to be able to start fresh, recreat

7条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 16:51

    My solution is best suited for :
    - deleted your mdf file
    - want to re-create your db.

    In order to recreate your database you need add the connection using Visual Studio.

    Step 1 : Go to Server Explorer add new connection( or look for a add db icon).

    Step 2 : Change Datasource to Microsoft SQL Server Database File.

    Step 3 : add any database name you desire in the Database file name field.(preferably the same name you have in the web.config AttachDbFilename attribute)

    Step 4 : click browse and navigate to where you will like it to be located.

    Step 5 : in the package manager console run command update-database

提交回复
热议问题