使用Active Directory集成的身份验证SQL Azure的数据库连接无法打开

问题描述:

我试图通过实体框架与类似下面的连接字符串连接到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

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

/// <summary> 
    /// HACK: Refer to https://*.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; 
    }