I'm trying to create a console application that will allow users to import large numbers of users into an existing ASP.Net MVC web app from CSV/Excel files. The code is as follows, and is taken from within a foreach loop iterating over ImportRecords:

WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", false);
WebSecurity.CreateUserAndAccount(importRecord.UserName, password);

I know the UserProfile table definitely exists as described, and the connection string is used elsewhere, so I know that that's fine too; here it is all the same:

<add name="DefaultConnection" connectionString="Data Source=[sql server];Initial Catalog=[database];User Id=[username];Password=[password];MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />

(Square brackets indicate where I have removed data for the sake of privacy).

I am however getting the following exception on the first of the two lines of code I have posted:

Attempt by method 'WebMatrix.WebData.SimpleMembershipProvider.ConnectToDatabase()' to access method 'WebMatrix.WebData.DatabaseConnectionInfo.Connect()' failed.

There is no inner exception or anything else of any use. I have tried reinstalling, upgrading and downgrading both WebMatrix.Data and WebMatrix.WebData but am not sure what else to try. Any ideas would be greatly appreciated!

0

There are 0 best solutions below