0

My brain is scrambled with this issue.

I've been following a tutorial on Seeding Users & Roles at the following link :-

http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user-properties/#comment-648

I get as far as attempting to update the database, which then should seed a User, but i get the following error message :-

You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.**

Another member posted this issue here :- Cannot seed Users & Roles

The resolution that was provided doesnt help me as I've got the correct version of the WebMatrix.WebData.Dll referenced in my project. (Version 2).

Other people have been able to follow the instruction without fault, it makes no sense. O have tried all of the work around's others have issued, but the fault wont shift.

Community
  • 1
  • 1
Derek
  • 8,300
  • 12
  • 56
  • 88

2 Answers2

0

I have managed solve this issue by ensuring the following references where added to my 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;
Derek
  • 8,300
  • 12
  • 56
  • 88
0

Read this blog post for an alternative method for seeding the users and roles that works automatically, not requiring the package manager. It includes a VS 2012 example project that you can download.

Kevin Junghans
  • 17,475
  • 4
  • 45
  • 62