MVC 4中的SQL Server Express数据库文件自动创建错误 - 但是我不想使用SQL Server Express [英] SQL Server Express database file auto-creation error in MVC 4 - But i DON'T want to use SQL Server Express

查看:90
本文介绍了MVC 4中的SQL Server Express数据库文件自动创建错误 - 但是我不想使用SQL Server Express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在ASP.Net MVC 4中部署了一个新的应用程序。我使用SQL Server 2008 R2(NOT SQL Express)。



前10分钟,然后我在代码中做了一些改动并重新部署了它。



现在,每当我尝试访问使用SimpleMembership的页面时,我得到此错误:


建立与SQL Server的连接时发生网络相关或实例特定的错误。服务器未找到或无法访问。验证实例名称是否正确,并将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 定位服务器/实例指定错误)



描述:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误的更多信息及其在代码中的位置。



SQLExpress数据库文件自动创建错误:

连接字符串使用应用程序的App_Data目录中的数据库位置指定本地Sql Server Express实例。提供者尝试自动创建应用程序服务数据库,因为提供程序确定数据库不存在。成功检查应用程序服务数据库的存在并自动创建应用程序服务数据库需要以下配置要求:


但是,我do 使用SQL Server Express。在我的 web.config 中,我设置了所有连接字符串如下:

 < add name =ApplicationServices
connectionString =Server = myServer; Database = myDB; User Id = myUserID; Password = myPWD;
providerName =System.Data.SqlClient/>

< add name =ApplicationServices
connectionString =Server = myServer; Database = myDB; User Id = myUserID; Password = myPWD;
providerName =System.Data.SqlClient/>

为什么不断尝试创建SQL Server EXPRESS 数据库? / p>

解决方案

你还有这个问题吗?另外,为什么你的ApplicationServices被列出了两次?



我曾经遇到过同样的事情。我在web.config中缺少配置文件和角色。

 < membership defaultProvider =AspNetSqlMembershipProvider> 
< providers>
< clear />
< add name =AspNetSqlMembershipProvider
type =System.Web.Security.SqlMembershipProvider
connectionStringName =ApplicationServices
enablePasswordRetrieval =false
enablePasswordReset =true
requiresQuestionAndAnswer =false
requiresUniqueEmail =false
maxInvalidPasswordAttempts =5
minRequiredPasswordLength =6
minRequiredNonalphanumericCharacters =0
passwordAttemptWindow =10
applicationName =Test/>
< / providers>
< / membership>
< roleManager enabled =truedefaultProvider =SqlRoleManager>
< providers>
< add name =SqlRoleManager
type =System.Web.Security.SqlRoleProvider
connectionStringName =ApplicationServices
applicationName =Test/>
< / providers>
< / roleManager>


I've just deployed a new application in ASP.Net MVC 4. I use a SQL Server 2008 R2 (NOT SQL Express).

It worked good for the first 10 minutes, then I did a little change in the code and re-deployed it.

Now, whenever I try to access a page that uses SimpleMembership, I get this error:

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: 26 - Error Locating Server/Instance Specified)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

But, I do not use SQL Server Express. In my web.config I've set all the connection strings as follows:

<add name="ApplicationServices" 
     connectionString="Server=myServer;Database=myDB;User Id=myUserID;Password=myPWD;" 
     providerName="System.Data.SqlClient" />

<add name="ApplicationServices" 
     connectionString="Server=myServer;Database=myDB;User Id=myUserID;Password=myPWD;" 
     providerName="System.Data.SqlClient" />

Why does it keep trying to create a SQL Server EXPRESS database?

解决方案

Are you still having this issue? Also, why do you have ApplicationServices listed twice?

I ran into the same thing a while back. I was missing the config in web.config for membership and roles.

<membership defaultProvider="AspNetSqlMembershipProvider">
  <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider"
         type="System.Web.Security.SqlMembershipProvider"
         connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="Test" />
  </providers>
</membership>
<roleManager enabled="true" defaultProvider="SqlRoleManager">
  <providers>
    <add name="SqlRoleManager"
         type="System.Web.Security.SqlRoleProvider"
         connectionStringName="ApplicationServices"
         applicationName="Test" />
  </providers>
</roleManager>

这篇关于MVC 4中的SQL Server Express数据库文件自动创建错误 - 但是我不想使用SQL Server Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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