在App_Data文件上传DBFile.mdf天青 [英] Upload DBFile.mdf in App_Data to Azure

查看:197
本文介绍了在App_Data文件上传DBFile.mdf天青的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我存储在/ App_Data目录的本地数据库ASP.NET MVC 3项目。这db是SQLEx preSS文件(* -mdf)。

I have my ASP.NET MVC 3 project with a local database stored in /App_Data directory. This db is SQLExpress file (*-mdf).

我有我的连接字符串中我的开发CPU完美的工作,连接字符串是:

I have my connection string working perfectly in my development CPU, the Connection String is:

数据源= \\ SQLEX $ P $干燥综合征;初始目录= CFCBBSecurity;集成安全性= SSPI; AttachDBFilename = | DataDirectory目录| \\ MYFILE.mdf;用户实例=真的providerName =System.Data.SqlClient的

data source=.\SQLEXPRESS;initial catalog=CFCBBSecurity;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MYFILE.mdf;User instance=true" providerName="System.Data.SqlClient"

当我把它上传到Azure中,使用VS 2010中,所有文件都在服务器上,但应用程序不能访问数据库。

When I upload it to Azure, using VS 2010, all files are in the server, but the application cannot access the Database.

我应该怎么做,改变或更新?

What should I do, change or update?

先谢谢了。

推荐答案

现在的问题是,你引用一个本地SQL实例(\\ SQLEX $ P $干燥综合征,在点代表本地主机)。我假设你正在你的机器上运行SQL Server 2005/2008/2012前preSS,这就是为什么这个工程在本地。

The problem is that you're referencing a local SQL instance (.\SQLEXPRESS, the 'dot' stands for localhost). I'm assuming you are running SQL Server 2005/2008/2012 Express on your machine and that's why this works locally.

但是,当你将应用程序部署到Windows Azure,还有安装在Web角色/ Worker角色/网站没有SQL服务器(这将是一个坏主意,反正,因为Web /工作者角色不是永久的!)。

But when you deploy your application to Windows Azure, there's no SQL Server installed on that Web Role/Worker Role/Web Site (this would be a bad idea anyways because Web/Worker Roles are not persistent!).

什么你需要做的是注册了像SQL Azure中的'云数据库并使用它。或者你可以自己主持它在Windows Azure的虚拟机(这是IaaS的,但是这需要更多的工作)。

What you'll need to do is sign up for a 'cloud database' like SQL Azure and use that. Or you could host it yourself in a Windows Azure Virtual Machine (which is IaaS, but this involves more work).

如果您正在构建一个MVC 3应用程序,我建议您只需使用SQL Azure的开始。这里是一个教程:<一href=\"http://blogs.msdn.com/b/webdev/archive/2011/08/11/running-asp-net-mvc-3-applications-on-azure.aspx\">Running ASP.NET MVC在Azure上 3应用程序(注意,本教程包含旧门户截图)。

If you're building an MVC 3 application I would suggest you simply start with SQL Azure. Here is a tutorial: Running ASP.NET MVC 3 Applications on Azure (note that this tutorial contains screenshots of the old portal).

这篇关于在App_Data文件上传DBFile.mdf天青的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆