asp.net-mvc – 在Azure上使用LocalDb MDF文件

我正在开发一个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,你必须确保数据库引擎被部署,你可以在本教程中找到相关说明:

http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-deploying-sql-server-compact-databases-2-of-12

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....