I am using visual studio express mvc4 for web to develope a web app with the out-of-the-box user management. I have two Models(AccountModels, Applicant),two Controllers(AccountController, ApplicantController) and two SQL Server DB(ApplicantDB, DefaultConnection
to UserProfile etc)
When I try to get the UserID of the current User to query a db table from the ApplicantController :
ok that was missing. Why wasnt it configured out of the box?
Now I receive the error: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
I must admit I have no experience with working with servers. If my questions are too basic could someone indicate a tutorial for that topic?
Is it correct that visual studio express 2012 for web does not create sql server itself? So I need to do that first, right?
I have Microsoft SQL Server 2012 LocalDB installed. So to create a local sql server I need to execute SqlLocalDB.msi?
Is there a tutorial for create a sql db server and provisioning it with the required schemas so that I can work with the Memebershipt framwork of asp.net mvc 4 in a web app?
SnafuBernd
Member
2 Points
11 Posts
"Membership.GetUser().ProviderUserKey" lead to "Unable to connect to SQL Server database"
Jan 25, 2013 09:23 AM|LINK
Hey,
I am using visual studio express mvc4 for web to develope a web app with the out-of-the-box user management. I have two Models(AccountModels, Applicant),two Controllers(AccountController, ApplicantController) and two SQL Server DB(ApplicantDB, DefaultConnection to UserProfile etc)
When I try to get the UserID of the current User to query a db table from the ApplicantController :
I receive the error: Unable to connect to SQL Server database. Pointing to the code line :
Both SQL Server Db are existing in the DB-Explorer. Also the table "UserProfile" contains the registered Users.
Furthermore the connectionStrings seem to be fine:
<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Geliex-20130122212323;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Geliex-20130122212323.mdf" providerName="System.Data.SqlClient" /> <add name="ApplicantDBContext" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Applicants.mdf;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>Still when executing the index()-ActionResult in my Controller (not AccountController) I get the above mention error message.
CruzerB
Contributor
5399 Points
1098 Posts
Re: "Membership.GetUser().ProviderUserKey" lead to "Unable to connect to SQL Server database"
Jan 25, 2013 12:05 PM|LINK
Hi,
Have you configured the membership provider to use the connection string?
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20"> <providers> <clear/> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" ....... /> </providers> </membership>My Technical Blog
SnafuBernd
Member
2 Points
11 Posts
Re: "Membership.GetUser().ProviderUserKey" lead to "Unable to connect to SQL Server database"
Jan 25, 2013 07:38 PM|LINK
Hey,
ok that was missing. Why wasnt it configured out of the box?
Now I receive the error: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
I must admit I have no experience with working with servers. If my questions are too basic could someone indicate a tutorial for that topic?
Is it correct that visual studio express 2012 for web does not create sql server itself? So I need to do that first, right?
I have Microsoft SQL Server 2012 LocalDB installed. So to create a local sql server I need to execute SqlLocalDB.msi?
Is there a tutorial for create a sql db server and provisioning it with the required schemas so that I can work with the Memebershipt framwork of asp.net mvc 4 in a web app?
CruzerB
Contributor
5399 Points
1098 Posts
Re: "Membership.GetUser().ProviderUserKey" lead to "Unable to connect to SQL Server database"
Jan 25, 2013 11:33 PM|LINK
When I use VS2010, the database and default configuration are there. Anyways, you still can use the tools to create for you.
http://www.asp.net/web-forms/tutorials/security/membership/creating-the-membership-schema-in-sql-server-vb
And this link show the steps to do it.
My Technical Blog