VS 2013 Controller Scaffolding Fails for the ApplicationUser Model (Multiple object sets per type are not supported)

后端 未结 8 2450
死守一世寂寞
死守一世寂寞 2020-12-08 11:07

In a VS 2013 RTM, MVC 5 project with EF 6, I tried to scaffold a controller based on the ApplicationUser (default with individual accounts authentication). Both Applic

8条回答
  •  旧时难觅i
    2020-12-08 11:33

    If you are trying to create an ApplicationUsersController please follow these steps.

    1. Delete this line from IdentityModels.cs

      public System.Data.Entity.DbSet ApplicationUsers { get; set; }
      
    2. Build the project

      control + shift + b
      
    3. Generate the controller

      Right click on the 'Controllers' folder.
      Add > Controller
      MVC Controller with views, using Entity Framework
      Model Class: ApplicationUser
      Add
      
    4. Go back to IdentityModels.cs and delete this line AGAIN

      public System.Data.Entity.DbSet ApplicationUsers { get; set; }
      
    5. Build the project

      control + shift + b
      
    6. Change the database calls to from ApplicationUsers to Users in ApplicationUsersController.cs

      control + f to bring up 'Find and Replace'
      Click 'Replace in files'
      Find what: db.ApplicationUsers
      Replace with: db.Users
      Replace All
      
    7. Press play and cross fingers :)

提交回复
热议问题