我正在構建一個ASP.NET,代碼優先的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
這個錯誤讓我相信,我有我的連接字符串的問題。當使用單元測試,我得到的錯誤:
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'.
最近,我改變了我的上下文構造來自:
public Context() : base("[server_Name].[database_name]")
{}
到:
public Context() : base("[server_Name].[full_company_server_file_path]")
{}
而當我跑的解決方案在本地,也得到了「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>
我的問題是:
爲什麼我需要爲了讓這一切工作創建數據庫的權限? 如果情況並非如此,爲什麼我一直得到這個錯誤? (沒有在我的代碼中,我說創建數據庫,也不應該/我可以)。
其次,有關修復我的連接字符串的任何建議?我從數據庫 - >屬性 - >連接字符串得到了這個connectionString(所以我覺得它是正確的)。
感謝您的所有幫助/提示/解釋。
使用:
- ASP.NET /實體框架/ C#
- 的Visual Studio 2015年
- SQL Server Management Studio中2014
您可以在該服務器上手動創建數據庫嗎?我的意思是通過登錄提供的憑據直接到SQL管理工作室的SQL服務器。 – Amir
我不確定我是否可以,但我不認爲。這是一家非常大的公司,我不想這樣做。 – swallis1
如果您可以創建任何測試數據庫並在稍後將其刪除並發現您有權限,則會更好。 – Amir