我的大脑对这个问题很不满。
我一直在关注Seeding Users&角色在以下链接: -
我试图更新数据库,然后应该为用户播种,但是我收到以下错误消息: -
您必须调用“WebSecurity.InitializeDatabaseConnection”方法 在调用“WebSecurity”类的任何其他方法之前。这个电话 应放在站点根目录中的_AppStart.cshtml文件中。**
另一位成员在此处发布了此问题: - Cannot seed Users & Roles
提供的解决方案对我没有帮助,因为我已经获得了项目中引用的WebMatrix.WebData.Dll的正确版本。 (第2版)。
其他人已经能够无故障地遵循指示,这没有任何意义。我已经尝试了其他人发布的所有工作,但错误不会改变。
答案 0 :(得分:0)
我已通过确保添加到Configuration.cs的以下引用来解决此问题: -
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using WebMatrix.WebData;
using WebMatrix.Data;
using System.Web;
答案 1 :(得分:0)
Read this blog post for an alternative method for seeding the users and roles自动运行,不需要包管理器。它包括一个可以下载的VS 2012示例项目。