在发布到Azure的地方时,但不能跑了Azure的SQL数据库工作 [英] Azure SQL database working when ran locally but not when published to Azure

查看:95
本文介绍了在发布到Azure的地方时,但不能跑了Azure的SQL数据库工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经破解了我几天了,我只是无法解决这个问题。

This has been cracking me up for a few days now and I just can't solve it.

我跟着您展示如何连接和使用实体框架内的模型第一种方法使用Azure数据库的在线教程。有了这个,你必须设置数据库迁移作为更新发布网站,以天青当Azure数据库。

I followed an online tutorial showing you how to connect and use an Azure database using the model first approach within Entity Framework. With this you had to set up database migrations as to update the Azure database when publishing the website to Azure.

我已经创造了在Azure上的数据库,所以我想我会采取使用一个数据库,第一个模型的方法(也它并不需要迁移是设置)和使用的实体框架向导来创建我的模型。一切都工作正常,当我在本地运行我的MVC网站把它连接到我的Azure数据库并显示数据等。然而,当我在网站发布到Azure的网站,出于某种原因,当我点击选项卡使用该控制器从数据库中获取数据,我得到一个错误:

I had already created a database on Azure so I thought I would take the approach of using a database first model (also it didn't require migrations to be setup) and used the Entity Framework wizard to create my model. Everything worked perfectly and when I run my MVC website locally it connects to my Azure database and shows the data, etc. However, when I publish the website to the Azure website, for some reason, when I click on tab that uses the controller that gets data from the database, I get an error:

抱歉,在处理您的请求时出错。

Sorry, an error occurred while processing your request.

我已经检查了我的连接字符串和它们似乎都确定,正如我所说的,当我运行在本地,我可以得到从Azure数据库中的数据。出于某种原因,虽然,我不能,一旦其公布的获得数据。

I have checked my connection strings and they all seem OK and as I said, when I run it locally I can get the data from the Azure database. For some reason, though, I can't get the data once its published.

任何想法?

推荐答案

三江源大家对你的帮助。

Thankyou everyone for your help.

我压根没想到打开副本本地然而,当我检查它被设置为true。因此,没有答案有:(

I didn't even think of turning on the copy local however when I checked it it was set to true. So no answer there :(

接下来,我加入的customErrors模式关闭尝试并获得更详细的说明。我得到的错误是巨大的,真的没有多大意义,所以我做了平常的事情,一派错误,我发现这个

Next I added the customerrors mode to off to try and get a more detailed description. The error I got was huge and really didn't make much sense so i did the usual thing and googled the error and I found this

<一个href=\"http://stackoverflow.com/questions/9591929/can-anyone-spot-why-i-keep-getting-this-error-testing-the-ef-5-beta\">Can任何人发现为什么我不断收到此错误测试EF 5测试版

当我读它,我知道这会解决它。我原先设置的项目作为.NET 4.5的项目,直到我意识到,却又如此我改成了.NET 4中,一旦我卸载EF蔚蓝的网站并没有与工作4.5和重新安装的一切工作。

As soon as I read it i knew this would fix it. I originally setup the project as a .net 4.5 project until I realized that azure websites didn't work with 4.5 yet so I changed it to .net 4 once I uninstalled EF and reinstalled it everything work.

感谢您的帮助。这已经阻止我了好几天做任何事情:P

Thanks for all your help. This has been stopping me doing anything for a few days :P

这篇关于在发布到Azure的地方时,但不能跑了Azure的SQL数据库工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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