1

While deleting an .mdf according to this article, I completed all the steps successfully. But, after deleting .mdf according to this step:

From Solution Explorer, click the Show All Files icon, then right click Add_Data\aspnet-MvcAuth-.mdf and click Delete.

when I typed Enable-Migrations into the PM-console, I got the message:

Migrations have already been enabled in project 'ContactManager'. To overwrite the existing migrations configuration, use the -Force parameter.

After this I launched it in Internet Explorer. There was no form to register with birthday. I made all the steps according to the article.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
S. Koshelnyk
  • 478
  • 1
  • 5
  • 20
  • 1
    Have you trying to re-create DB using Code First Migrations? Remove all existing migrations in Migrations directory right after deleting MDF file, then execute `Add-Migration InitialCreate` and `Update-Database` in Package Manager Console. – Tetsuya Yamamoto Jan 25 '17 at 08:45
  • @Tetsuya Yamamoto, I tried to type: "Enable-Migrations -EnableAutomaticMigrations -Force" there was successfull. Then I typed: "Add-Migration Initial -Force". I got: "Re-scaffolding migration 'Initial'.". But when I typed: "Update-Database" I got this: "Error Number:2714,State:6,Class:16 There is already an object named 'AspNetRoles' in the database." – S. Koshelnyk Jan 25 '17 at 08:58
  • 1
    Change `Add-Migration` command into `Add-Migration Initial -Force -IgnoreChanges`, then try `Verbose` switch when updating DB: `Update-Database -verbose`. – Tetsuya Yamamoto Jan 25 '17 at 09:04
  • @Tetsuya Yamamoto, **PM> Add-Migration Initial -Force -IgnoreChanges** I got **Re-scaffolding migration 'Initial'.** Then **Update-Database -Verbose** I got **..........ClientConnectionId:1ec44fb6-b824-4095-8c87-698af8a6d0ea Error Number:2714,State:6,Class:16 There is already an object named 'AspNetRoles' in the database.** – S. Koshelnyk Jan 25 '17 at 09:13
  • For `AspNetRoles` table issue after `Update-Database`, check these: http://stackoverflow.com/questions/34606160/there-is-already-an-object-named-aspnetusers-in-the-database & http://stackoverflow.com/questions/24169140/there-is-already-an-object-named-aspnetroles-in-the-database. Note that you may need to comment some relationships-related code lines before adding migration. – Tetsuya Yamamoto Jan 25 '17 at 09:28
  • @S.Koshelnyk I have tidied up your question and I hope it now reads correctly. Please [edit] it if I have made any mistakes. – AdrianHHH Jan 25 '17 at 11:22
  • @AdrianHHH, its ok. Thanks. – S. Koshelnyk Jan 25 '17 at 12:51

0 Answers0