Monday, May 23, 2011

SQL Server Compact ASP.NET Membership, Role and Profile Provider version 2.1 now available

My ASP.NET membership provider is now available in version 2.1, that contains many improvements and some new features based on excellent community feedback – keep it coming!

The ASP.NET membership provider project was prompted last July by the comments to Scott Gu’s blog post about the upcoming version 4.0 of SQL Server Compact, and it’s support for ASP.NET.

Basically the Gu said: “We are looking to potentially ship a set of providers that work with it (and do not use stored procedures). The first beta won't have this - but it is something we'll hopefully enable in the future.”

So it was time to start coding, since the absence of a Membership provider would make SQL Server Compact less of an attractive option for ASP.NET web sites.

Since then, the database schema used has been refactored to be in line with the ASP.NET 4.0 SQL Server based schema, which resulted in the first NuGet Package being released in January 2011.

Now version 2.1 is available, also via NuGet:


Or from the CodePlex site.

The new features in version 2.1 are:
Profile provider included (contrib davidsk)
Two new methods: UpdateUserName and MigrateMembershipDatabaseToAspNet40 (contrib nekno)

Bug fixes (by various contributors, thank you all):
UpdateUser() doesn't set LoweredEmail
GetUser w/ providerUserKey returns invalid information
Static salt leads to deterministic output, dynamic salt is better
Configuration error when using a provider


Aabhushan said...

How do I create the database for this?

ErikEJ said...

You don't need to, the provider creates it for you

bmosbarg said...

Could you please describe the best method to perform a password reset for users? A method that the user could perform with no administration intervention.

ErikEJ said...

Something like: aspUser.ChangePassword(aspUser.ResetPassword(), newPassword);

Mehmet AV┼×AR said...

great work.

JramirezDev said...

Hello Erik,

I am using your SQL CE 4 provider for autehntication and role authorization, but i am also using EF for query the database, so when i deployed the app i get the following error:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

Line 75:
Line 76: <add name="SqlCeRoleProvider"
Line 77: type="ErikEJ.SqlCeRoleProvider"
Line 78: connectionStringName="SqlCeServices"
Line 79: applicationName="/"

Source File: E:\web\jramirez\myapps_segurosjuank\web.config Line: 77

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91' could not be loaded.

I just used the Assemblies that are in my local: C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private

But does not works :(

I would appreciate your help

ErikEJ said...

Hi Jamirez, suggest you use the Microsaoft supported provider form NuGet, I no longer support this - and do not use the files from the Private folder on a web server.

JramirezDev said...

Hi Erik, do you have an example about how to use the Microsft supported provider? and whatwhat is his name? I wrote all my code using your implementation... can i change to this one with my current code? Thanks.

JramirezDev said...

Hello Erik, I was fine implementing the microsoft provider. now i am having another issue about the session time, i'm using roles authorization and forms authentication (with login control).

After login the session time is variable, some times it takes 5 minutes, sometimes just 1 minute... could you help me to identify whats the problem?

ErikEJ said...

jamirez: It is the same AP, yes

ErikEJ said...

Jramirez: Suggest you ask in the ASP.NET forums