我正在开发一个ASP.NET MVC网站,我想在Azure网站上托管。在开发过程中,我一直在我的App_Data目录中使用一个MDF文件,连接字符串如下所示:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MyApp;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MyApp.mdf;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
要在Azure上尝试,我希望我可以保留此连接字符串,只是FTP我的MyApp.mdf到Azure上的App_Data文件夹,因为它都设置了我想要使用的示例数据。但是,当我试图访问我的网站,我碰到以下错误:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces,error: 52 – Unable to locate a LocalDB
installation. Verify that SQL Server Express is properly installed and
that the LocalDB feature is enabled.)
我的问题是,有没有办法我可以运行我的Azure网站连接到MDF文件在我的App_Data文件夹,或者我被迫使用Azure SQL数据库?
解决方法
您不能在App_Data中使用.mdf文件,但不会强制使用SQL Azure – 您可以使用SQL Server Compact。如果您使用Code First迁移,从LocalDB到Compact的部署很容易;否则您将在部署之前迁移到SQL Server Compact。如果你决定使用Compact,你必须确保数据库引擎被部署,你可以在本教程中找到相关说明:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。