简体   繁体   English

我的网络应用程序在发布时找不到我的数据库

[英]My web app doesn't find my database when published

I created a simple web app with Visual Studio 2012, using MVC3 and published it on Azure. 我使用Visual Studio 2012创建了一个简单的Web应用程序,使用MVC3并在Azure上发布。

When I run it locally, everything works fine. 当我在本地运行它时,一切正常。 But when I publish, one page where there is a table that use a db I created don't load. 但是当我发布时,一个页面中有一个使用我创建的数据库的表不会加载。 The error message is enormous, but start like this: 错误消息是巨大的,但是从这样开始:

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the   file specified

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.

Stack Trace: 


[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): 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 Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558

And go on and on. 然后继续。

There are three tables, one is the Default that is created by Visual Studio on its Web App sample. 有三个表,一个是Visual Studio在其Web App示例上创建的Default。 The other two I created on my own, and neither of them works when published (run perfectly fine when local). 我自己创建的另外两个,在发布时都不起作用(在本地时运行完全正常)。

I assuming the problem is on the Connection Strings, if there is anything more I should present here, please ask: 我假设问题出现在连接字符串上,如果我还有更多内容,请询问:

<connectionStrings>
 <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Porta-comprimidos-20130503163319;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Porta-comprimidos-20130503163319.mdf" />
<add name="RemedioDBContext"
  connectionString="Data Source=|DataDirectory|\MeuPortaComprimidosDB.sdf"
  providerName="System.Data.SqlClient"/>
<add name="RemedioTempDBContext"
  connectionString=""
  providerName="System.Data.SqlClient"/>

Can anyone, please, help me? 谁能帮帮我吗? I researched it a lot and have no idea how to handle it (yes, I am new into this). 我研究了很多,不知道如何处理它(是的,我是新手)。

Your connection strings are settings the data source to LocalDb which is not installed by default on Windows Azure machines and you cannot use it (unless you install it). 您的connection strings是将数据源设置为LocalDb设置,默认情况下,Windows Azure计算机上未安装该数据源,您无法使用它(除非您安装它)。

You have to migrate your database to Windows Azure SQL and change your connection string accordingly. 您必须将数据库迁移到Windows Azure SQL并相应地更改connection string

More info on http://msdn.microsoft.com/en-us/library/windowsazure/ee730904.aspx 有关更多信息,请访问http://msdn.microsoft.com/en-us/library/windowsazure/ee730904.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我从Visual Studio发布到Azure时,我的数据库没有发布,因此任何需要中断的功能 - When I publish from Visual Studio to Azure my database doesn't get published and so any functionality requiring that breaks 当我在另一台 PC 上安装 C# 应用程序时,数据库无法正常工作 - When I install my C# app on another PC, the database doesn't work 发布我的C#项目时数据库无法正常工作 - Database not working when published my c# project 我的应用程序不使用SQL Server Express,但它正在寻找App_Data中的数据库 - 为什么? - My app doesn't use SQL Server Express but it is looking for a database in App_Data — why? 数据库文件未出现在我的资源管理器中 - database file doesn't appear in my explorer 函数未向我的数据库添加数据 - Function doesn't add data to my database 为什么我的代码不更新数据库? - Why Doesn't my Code Update The database? DotNetOpenAuth模板在发布时不起作用 - DotNetOpenAuth template doesn't work when published 我的XNA应用程式无法正确呈现 - My XNA app doesn't render correctly 在为.net core 2.1.5 Web应用程序生产时,Serilog不会在MSSqlServer数据库中创建日志 - Serilog doesn't create logs in MSSqlServer database when in production for .net core 2.1.5 web app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM