我在 Web 配置中有以下连接字符串,并且在 Visual Studio 中工作正常。
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-MyPortal-20170627104450.mdf;Initial Catalog=aspnet-MyPortal-20170627104450;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
我尝试使用 Azure 应用服务和 Azure AD 将 ASP.NET MVC 应用程序移植到 Azure。我更改了 AttachDbFilename 属性,如下所示
AttachDbFilename=\App_Data\aspnet-MyPortal-20170620051631.mdf
我收到以下错误:
Invalid value for key 'attachdbfilename'.
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: Invalid value for key 'attachdbfilename'.
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.
App Data 文件夹包含 mdf 文件。如何在 Web 配置的连接字符串中引用它?
是否有 Azure Web 应用程序通过 Azure AD 进行身份验证的示例程序?
最佳答案
简而言之,您无法在 Azure 应用服务中使用 LocalDB。
还有另一个答案 - How to connect a localdb from Visual Studio to the published Azure web app?
关于c# - 在 Azure 应用服务中使用 LocalDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44841031/