- .Net4.0
- MVC 2
- NHibernate
- NUnit
I’m trying to test user creation. From my test, I’m calling the following:
MembershipCreateStatus status;
// _session is my current NHibernate session.
var mmp = new MyMembershipProvider(_session);
mmp.CreateUser(username, password, "something@example.com", "", "", true, Guid.NewGuid(), out status);
In the CreateUser method, it gets this far:
var user = new MembershipUser(Name, username, providerUserKey, email, passwordQuestion, passwordAnswer, isApproved, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
… before throwing this exception:
The membership provider name specified is invalid.
Parameter name: providerName
I have my Name set to MyMembershipProvider, and in the Web.config I have this:
<add name="OnyxMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
And also, my connection string:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
Now, I’m guessing the the problem is that my tests are creating a SQLite DB, and the web.Config is trying to hit my SqlServer DB, but I’m not sure how to proceed.
Shouldn’t the name be the same as that specified in the web.config?
i.e. OnyxMembershipProvider