ASP.Net MVC 3配置 [英] ASP.Net MVC 3 Configuration

查看:124
本文介绍了ASP.Net MVC 3配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想请教一下ASP.Net配置。我有使用ASP.Net MVC3的项目。我用会员在我的项目。在我的数据库服务器中,有一个为我的项目2个数据库。

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,包含aspnet_membership,aspnet_user,aspnet_roles等(我用asp.net配置)

  2. MyDatabase的,它为我的项目数据库。

现在我的老板告诉我,他希望我主持的公共项目,并告诉我只用一个数据库。所以我必须移动到ASPNETDB MYDATABASE。我怎么能做到这一点,而不在MyDatabase的制作新的表?

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 ?

感谢

推荐答案

默认情况下,ASP.NET成员资格提供程序使用一个内置的ConnectionString名为 LocalSqlServer 这是一样的东西这样的:

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"/>

当你使用成员首次(或当您使用Web配置管理工具),在 ASPNETDB.MDF 将被自动创建。对于第一个步骤,你可以删除该的connectionString 的web.config 明确命令:

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>

和也,则必须更改的connectionString 的MembershipProvider (也是 roleProvider <在的web.config / code>如果您使用它)文件:

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>

有关数据库配置为使用 ASP.NET 内置成员提供程序,您可以使用regsql工具
可以在这里成立:

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)\

在此文件夹中,找到 aspnet_regsql.exe的文件并运行它。一个有用的向导将被显示,并
帮助你一步一步来配置新的数据库。而关于你的最后一个问题:你还没有申请任何改变
你的 EDMX 文件! EF英孚将与您提供给它的表,和的MembershipProvider 做好分内的工作与
表ASP.NET 提供给它!干得好,干得好!

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!

这篇关于ASP.Net MVC 3配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆