views:

270

answers:

3

I am trying to develop a website with C# ASP.net MVC. It's my first time using Visual Studio, C# and ASP.net so I have lots to learn but so far so good. So far... I started a C# ASP.net MVC project and added a database by going to the Database Explorer and clicking "add connection". I then did some standard CRUD controllers and views.

I am at the stage where I want to implement User authentication. I'm a bit confused here. I am trying to make a custom Membership Provider. So I added it to my web.config file with the correct connection string etc. When I run the project and go to register I get an error. "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'."

From searching, I see lots of people have this problem and they always reference their hosting. People say this (http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx) is their solution but when I try pick a database I get an error. Not even sure of my server name. So at this point I am wondering, did I set up the database right?

EDIT

Adding in a few pics to show exactly what I am doing. This is the aspnet_regsql.exe: alt text alt text

This is the provider with connection string, taken from an example on one of the links given. alt text This is my customized provider with connection string pointing to the last image. alt text

This is a screen cap when I run the project and go to the default project Account register action: alt text

and finally, this is the error screen when I submit alt text

EDIT

Another update..

I sorted something out but I am not sure if it is correct. I am now getting an error when the page loads: "Invalid object name 'dbo.Tag'"

+2  A: 

In order to solve this problem the only thing you need to do is create an application services DB. You can achieve this by running the following command from your Visual Studio Command Prompt

aspnet_regsql

Anyways it seems that your "custom provider" isn't using a custom structure for your DB, which might be the reason why you weren't expecting this error.

If you are using the default implementation, you can access to the user administration using ASP .NET Configuration, located on your project menu in visual studio.

The default implementation uses the following conn string keyword

LocalSqlServer

The are many ways of implementing the membership provider. My guess is that probably this conn string is not pointing to your aspnet services db, you could do something like this to specify a custom location for this db

<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnetdb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />

I made a blog post regarding this topic http://tinyurl.com/ygvum8y.

Raúl Roa
My username and password are my Windows ones?
RogerDelta
No, I updated the answer. Now the connstring attaches the mdf located on your App_Data using integrated auth.
Raúl Roa
A: 

It's hard to figure out anything from your post.

but when I try pick a database I get an error.

You can check your server name in Surface area configuration or Sql Server Configuration Manager. If you installed Visual Studio it's probably YOUR_MACHINE_NAME\SQLEXPRESS. You can connect to it using Windows Authentication. You could also write localhost,1433 instead, but that would require enabling TCP/IP first(it's disabled by default) and setting the port number first(which in most cases is already set).

kubal5003
Thanks, without the \SQLEXPRESS, I wasn't able to do anything with the aspnet_regsql.exe.
RogerDelta
A: 

Have you tried changing the data source in the localSqlServer connection string from localhost to xxx\SQLSERVER?

schdr