如何允许IIS从ASP.NET MVC项目中使用本地数据库? [英] How to allow IIS to use local database from ASP.NET MVC project?

查看:133
本文介绍了如何允许IIS从ASP.NET MVC项目中使用本地数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在本地网络上进行demoing一个ASP.NET MVC的网站。此应用程序有一个数据库的连接:

I'm going to be demoing a ASP.NET MVC website on a local network. This application has a connection to a database:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-EBC-20141127093222.mdf;Initial Catalog=aspnet-EBC-20141127093222;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

我想如果这个数据库可以通过IIS和每当我跑我的应用程序在本地使用我已在IIS网站 - 它是运行.NET V4。我的项目住在 C:\\的Inetpub \\ WWW \\ EBC 。我可以发布网站,但在查看网页收到此错误:

I would like if this database can be used by both IIS and whenever I run my application locally. I've made a site on IIS - it is running .NET v4. My project lives in c:\inetpub\www\ebc. I can publish the website but recieve this error upon viewing the page:

发生网络相关的或特定于实例的错误,服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:50 - 发生本地数据库运行时错误的LocalDB实例API方法调用内发生意外错误,请参阅Windows应用程序事件日志中的错误信息

"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: 50 - Local Database Runtime error occurred. Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application event log for error details."

我知道我需要允许通过Microsoft SQL Server的管理中心的SQL服务器的远程连接?有没有办法做到这一点在其他地方?

I know I need to allow remote connections to the sql server through microsoft sql server manager? Is there a way to do it elsewhere?

推荐答案

在有安装在一台机器的SQL Server的LocalDB的多个版本,这个错误是很常见的。

When there are multiple version of SQL Server localDB installed in a machine, this error is very common.

尝试使用(的LocalDB)\\ mssqllocaldb ,作为一个普通的服务器名称进行连接,而不是11.0到自动的LocalDB实例,或V12.0

Try to use (localdb)\mssqllocaldb, as a common server name to connect to the LocalDB automatic instance, instead of "v11.0" or "v12.0".

以上的自动的LocalDB实例中,有一个默认的名字在所有版本,避免名称与放大器之间的冲突;版本。

The above automatic localdb instance, have a default name across all the version and avoid conflict between name & version.

重要提示:当更新的LocalDB到新版本,记得用旧版本创建无法与较新的工作数据库

Important: When updating the localdb to new version, remember the database created with an older version does not work with the newer.

这篇关于如何允许IIS从ASP.NET MVC项目中使用本地数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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