Jesus Jimenez
Jesus Jimenez

Reputation: 165

How do I create AspNet Membership database in SQL Server CE

I'm working on a small website and I want to include the Asp.Net Membership to manage the users and roles in the application.

I've done this in the past but always using SQL Server or SQL Server Express as database engine. Now I want to use it with SQL Server CE because of my hosting provider and I'm facing the most ridiculous problem ever. I don't know how to create the database itself.

The script generated by aspnet_regsql with "exportonly" option doesn't work and specifying the connection string with -C option doesn't work for me too.

I read about how to use the new a Microsoft ASP.NET Universal Providers for SQL Compact Edition 1.0 or the a SQL Compact ASP.NET Membership, Role and Profile provider from ErikEJ, but can't even try this providers without the database.

Does anyone knows how to do that?

Maybe I'm totally wrong in my expectations so I accept advises also. My only requirement is that it must be with SQL Server CE 4.0.

Even if there is another simple way to manage users and roles besides the asp.net membership I'm all ears!

Thanks, J.

Upvotes: 1

Views: 2592

Answers (1)

marc_s
marc_s

Reputation: 754258

I just

  • created a brand-new ASP.NET MVC 3 web project
  • installed the Microsoft SQL Server CE 4.0 Membership & Role provider (from your link) using NuGet
  • launched that app
  • registered on my MVC site giving a user name and a password

After that:

  • I found the aspnet.sdf SQL Server CE 4.0 database sitting in my App_Data folder

So basically: just install and use it! The database file will be created as needed.

Now that you have an aspnet.sdf database file (with a single user), you can back that up and use it in future projects as a starting point, if you like.

Upvotes: 1

Related Questions