2017-08-09 71 views
1

我試圖通過實體框架與類似下面的連接字符串連接到SQL Azure的數據庫:使用Active Directory集成的身份驗證SQL Azure的數據庫連接無法打開

Data Source=<server>.database.windows.net;Authentication=Active Directory Integrated;Initial Catalog=<database>

連接嘗試在託管的WPF表單的上下文中運行。該項目使用.NET Framework 4.6和EF 6.1.3構建。

我遇到了以下錯誤:

Unable to load adalsql.dll (Authentication=ActiveDirectoryIntegrated). Error code: 0x2. For more information, see http://go.microsoft.com/fwlink/?LinkID=513072

不幸的是,幫助鏈接不會導致提供技術細節,針對此問題頁面。到目前爲止,我還沒有在網絡上發現任何解釋根本原因的東西。

我也試過此連接字符串:

Server=tcp:<server>.database.windows.net,1433;Initial Catalog=<database>;Persist Security Info=False;User ID=<username>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Integrated"

它是從Azure的門戶網站的ADO.NET (Active Directory integrated authentication)部分複製。但是,通過此連接字符串,我得到以下錯誤Cannot use 'Authentication=Active Directory Integrated' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords

但它不包含密碼段。在刪除User ID段後,我仍然收到Unable to load adalsql.dll ...錯誤。

+0

是ü能解決這個問題?請讓我們知道。由於我們面臨同樣的問題,這將有所幫助。 –

+0

不,我從來沒有解決。我結束了使用SQL Server密碼身份驗證,而不是AD身份驗證。 – CalvinDale

回答

0

連接字符串 Server=<server>.database.windows.net,1433; Authentication=Active Directory Integrated; Initial Catalog=<database>; 作品如果按照這個技巧:

/// <summary> 
    /// HACK: Refer to https://stackoverflow.com/a/19130718/852956 
    /// </summary> 
    public void FixEfProviderServicesProblem() { 
     //The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' 
     //for the 'System.Data.SqlClient' ADO.NET provider could not be loaded. 
     //Make sure the provider assembly is available to the running application. 
     //See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. 

     SqlProviderServices instance = SqlProviderServices.Instance; 
    } 
相關問題