私は、Visual Studio 2013 ExpressのコードファーストワークフローであるEntity Framework 6を使用してASP.NET MVC 5でアプリケーションを構築しました。アプリケーションはローカルホスト上で正常に動作します。ASP.NET MVCのホスティングサーバー上のLocalDbデータベースをSQL Serverデータベースに移動するにはどうすればよいですか?
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-ERPCLINIC-20170908103952.mdf;Initial Catalog=aspnet-ERPCLINIC-20170908103952;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="SchoolContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ERPCLINIC.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
者がローカルホストサーバー上のweb.config
に含まれています。
以下では、出版前に私の接続文字列です。
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=197.189.255.211 (MS SQL Server);Initial Catalog=qffienta_mat;User Id=qffienta_qffienta;Password=4uOHj7da65;"
providerName="System.Data.SqlClient" />
<add name="SchoolContext"
connectionString="Data Source=197.189.255.211 (MS SQL Server);Initial Catalog=qffienta_mat;User Id=qffienta_qffienta;Password=4uOHj7da65;"
providerName="System.Data.SqlClient" />
</connectionStrings>
ここでも、それらをホストするサーバーにweb.config
に含まれています。以下
とは、出版後、私の接続文字列です。
自分のドメインで自分のアプリケーションを起動しようとすると、私は次のエラーを取得する:
Server Error in '/' Application.
No connection string named 'SchoolContext_DatabasePublish' could be found in the application config file.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: No connection string named 'SchoolContext_DatabasePublish' could be found in the application config file.
Source Error:
Line 5: var db = new SchoolContext();
Line 6:
Line 7: var mostRecentEntries =
Line 8: (from entry in db.Appointments
Line 9: orderby entry.ID descendingSource File:
c:\Websites\qffientasp.co.za\httpdocs\Views\Shared_Appointment.cshtml Line: 7 "
私は私のホスティングアカウントへのVisual Studio 2013 Expressでそれを展開し、発行が成功したが、私はそれにアクセスしようとしました私のドメインでは、データベースに接続できないようです。私は今何が問題なのかは分かりません。私は接続しようとしているホスティングアカウントから新しいデータベースを作成しました。