1

i want to ask about ASP.Net Configuration. i have a project that use ASP.Net MVC3. and i use membership in my project. in my database server, there's 2 database for my project.

  1. aspnetdb, contains aspnet_membership, aspnet_user, aspnet_roles, etc (i use asp.net Configuration)
  2. mydatabase, its for my project database.

now my boss told me that he want to host my project in public and told me to use only one database. so i have to move aspnetdb to mydatabase. how can i do it without making new table in mydatabase ?

thanks

6
  • You just need to move the asp_net tables into mydatabase. Obviously you have to create these tables in mydatabase, unless you already have your own user schema? Commented Sep 23, 2011 at 8:10
  • thanks thecodeking for reply. but if i host my project, can i use those table ? i mean that i still use two database ( because there's a lot to do if i making new table in mydatabase). Commented Sep 23, 2011 at 8:17
  • 1
    What's the question? You can use two databases if your hosting provider allows it, or you can move those existing tables into the one database, what's a lot of work? Commented Sep 23, 2011 at 8:20
  • i mean if i move my aspnetdb to mydatabase, is there any change in my edmx file ? Commented Sep 23, 2011 at 8:45
  • The only change is the connection string, and asp.net sql membership providers don't use the entity framework anyway. Commented Sep 23, 2011 at 8:46

2 Answers 2

1

By default the ASP.NET membership provider uses a built-in connectionString named LocalSqlServer which is something like this:

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

and when you use the Membership for first time (or when you use the web configuration manager tool), the aspnetdb.mdf will be created automatically. For first step, you can remove this connectionString from web.config by clear command:

  <connectionStrings>
    <clear/>
    <!-- your other connectionStrings -->
  </connectionStrings>

and also, you must change the connectionString for membershipProvider (and also roleProvider if you use it) in web.config file:

<membership userIsOnlineTimeWindow="20">
  <providers>
    <clear />
    <add
         connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlMembershipProvider" 
         type="System.Web.Security.SqlMembershipProvider" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         maxInvalidPasswordAttempts="500" 
         minRequiredPasswordLength="1"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="/" />
  </providers>
</membership>

<roleManager enabled="true">
  <providers>
    <clear/>
    <add connectionStringName="YourSpecifiedConnectionString" // your connectionString here
         name="AspNetSqlRoleProvider"  
         applicationName="/" 
         type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</roleManager>

For configure the database to use ASP.NET built-in membership provider, you can use regsql tool which can be founded here:

C:\Windows\Microsoft.NET\Framework\(version that you are using. mine is v4.0.30319)\

In this folder, find the aspnet_regsql.exe file and run it. A helpful wizard will be shown and help you step by step to configure new database. And about your final issue: You haven't to apply any change to your edmx file! The EF works with tables you supplied to it, and membershipProvider do its job with tables that ASP.NET supplied to it! Well done, Good job!

Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome (^_^) and thank you to accept. If this answer is helpful, vote it up please. Thank you again. Regards.
0

You have to add those tables to your own database. It's quite easy. Just use the aspnet_regsql tool to export the database schema to a SQL file and run that file in your own database.

Instruction: http://www.xdevsoftware.com/blog/post/Install-ASPNET-Membership-Provider-on-a-Shared-Hosting-Company.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.