2017-09-12 5 views
0

私は、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 descending

Source File:
c:\Websites\qffientasp.co.za\httpdocs\Views\Shared_Appointment.cshtml Line: 7 "

私は私のホスティングアカウントへのVisual Studio 2013 Expressでそれを展開し、発行が成功したが、私はそれにアクセスしようとしました私のドメインでは、データベースに接続できないようです。私は今何が問題なのかは分かりません。私は接続しようとしているホスティングアカウントから新しいデータベースを作成しました。

答えて

0

エラーが真伝えます:

あなたのconnectionStringsセクションにその名前を持つ接続です

No connection string named 'SchoolContext_DatabasePublish' could be found in the application config file.

?また、あなたの接続文字列に '(MS SQL Server)'があるのはなぜですか? ip(、port)またはdbサーバー名(/インスタンス名)が必要です。

public SchoolContext : base("SchoolContext") 
0

本当にありがとうございました:

は、コンストラクタで接続名を指定して、正確に試してみてください。問題は私が間違ってサーバー名を入れていたことです。私は、リモートサーバに二つの新しいデータベースを作成し、私の接続文字列は次のようになります。

<add name="SchoolContext" 
    connectionString="Data Source=197.189.255.211;Initial Catalog=qffienta_tar;User Id=qffienta_tar;Password=4uOHj7da65;" 
    providerName="System.Data.SqlClient" /> 

これはあなただけの新しいデータベースに一致するように接続文字列を変更する必要があるアプリケーションを公開するために、いくつかの他の人々を助けることを願って、ユーザーIDあなたが上記のようにパスワードを入力した場合、Web配置、データベース、リモート接続文字列を使用してビジュアルスタジオ2013を公開している場合、

データソース=サーバ名;初期カタログ=データベース名;ユーザID =ユーザー名;パスワード=あなたのパスワード;

サーバーにアプリケーションを配備する方法を理解するのに2日間を費やしました。

関連する問題