私はASP.NET、コードファーストのWebアプリケーションを構築しています。私は会社の所有するデータベースを使用しており、このサーバー上の1つのデータベース内のテーブルに対して完全な権限を持っています。私は "データベースの作成"権限を持っているとは思わない。私は私のWebアプリケーションを発行する問題に遭遇しています。私はローカルですべてを実行することができますが、私は会社のサーバー上でコードを公開すると、私のようなエラーが出る:このエラーは、私は私の接続文字列に問題があると考えていますなぜasp.net Webアプリケーション用のデータベース作成権限が必要なのですか?
Format of the initialization string does not conform to specification starting at index 0.
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.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +1742
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +191
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +136
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +75
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +35
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +241
System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) +78
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +116
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +104
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext) +434
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +39
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +160
System.Data.Entity.Internal.LazyInternalConnection.get_Connection() +16
[Project].DBContext.Context..ctor() in C:\Users\[UserName]\Documents\[FilePath]\[Project]\DBContext\Context.cs:20
[Project].Data_Manager.DataManager..ctor() in C:\Users\[UserName]\Documents\[FilePath]\[Project]\Data_Manager\DataManager.cs:15
[Project].Controllers.HeaderController..ctor() in C:\Users\[UserName]\Documents\[FilePath]\[Project]\Controllers\HeaderController.cs:12
を。また、
public Context() : base("[server_Name].[full_company_server_file_path]")
{}
そして、私は解決策を実行したときに、ローカル:
public Context() : base("[server_Name].[database_name]")
{}
へ:
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: CREATE DATABASE permission denied in database 'master'.
が、私は最近の私のコンテキストコンストラクタを変更:ユニットテストを使用している場合、私はエラーを取得します「CREATE DATABASE permission denied in database 'master'
」というエラーが発生しました。レコードの
は、私の接続文字列は次のとおりです。
<connectionStrings>
<clear />
<add name="[server_Name].[database_name]" providerName="System.Data.SqlClient" connectionString="Data Source=[server_Name].[full_company_server_file_path];Initial Catalog=[database_name];Persist Security Info=True;User ID=userid;Password=password;MultipleActiveResultSets=True;Application Name=EntityFramework" />
< /connectionStrings>
私の質問は:
は、なぜ私はこのすべてが機能するためにはデータベースのアクセス権を作成します。必要なのでしょうか? そうでない場合は、なぜこのエラーが発生するのですか? (私のコードではDBを作成するとは言いませんし、そうしてはいけません)。
第2に、接続文字列を修正するための提案はありますか?私はデータベースから接続文字列を取得しました - >プロパティ - >接続文字列(私はそれが正しいように感じるので)。
すべてのヘルプ/ヒント/説明ありがとうございます。
- ASP.NET/Entity Frameworkの/ C#
- のVisual Studio 2015
- SQL Server Management Studioの2014
そのサーバーに手動でデータベースを作成できますか?私はSQL管理スタジオのSQLサーバーに直接提供された資格情報でログインすることを意味します。 – Amir
私はできるかどうかはわかりませんが、私はそうではないと思います。それは非常に大規模な会社であり、私はそのようなことをいじっているとは思わない。 – swallis1
テストデータベースを作成して後で削除して、権限があるかどうかを確認する方が良いでしょう。 – Amir