我有一個aspnetservicesdb數據庫用於存儲用戶配置文件。我部署了一個新的asp.net mvc應用程序。該應用程序在appdata目錄中使用本地sqlexpress數據庫以用於成員資格/配置文件目的。MVC應用程序正在尋找憑據在錯誤的數據庫
我不希望應用程序使用sqlexpress數據庫。
我已經從web.config和AuthConfig.RegisterAuth()中刪除了連接字符串; from global.asax
到目前爲止,這一直奏效。我能夠成功地在控制器中使用User.Identity.Name。但是,當我試圖在視圖中使用User.IsInRole時,由於本地sqlexpress數據庫不存在,我得到了一個sql server未發現的錯誤。
如何告訴應用程序使用我現有的數據庫並停止查找sqlexpress db?
編輯 - 這裏是連接字符串
<!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=removed;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|removed" providerName="System.Data.SqlClient"/>-->
<add name="ApplicationServices" connectionString="Data Source=removed;Initial Catalog=aspservicesdb;UID=removed;PWD=removed" providerName="System.Data.SqlClient" />
編輯 - 這裏是從Web配置
<authentication mode="Forms">
<forms loginUrl="~/login.aspx" timeout="2880" />
</authentication>
<membership userIsOnlineTimeWindow="480">
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="12" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
哪個版本的MVC?哪個會員提供商? (你說SqlMembershipProvider,但你確定?)SqlMembershipProvider在web.config中配置它的數據庫,所以你在那裏設置連接字符串。 EntityFramework與什麼有什麼關係? SqlMembershipProvider不使用EntityFramework。 –
是的,我確定。我已將連接字符串添加到原始問題中,包括localdb的註釋掉默認值。 – tintyethan
你可以分享你的實體上下文的定義嗎? –