c# - Entity Framework SQL connection issue after migration -


i've been tasked migrating application iis 6/sql server 8 iis 8/sql server 2008 r2. can run application vs2012 on local machine , connect local instance of sql 2008 r2, i'm getting following on new server:

a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)

i didn't build application, i'm little blind here, here connection string:

<add name="censusentities"                   connectionstring="metadata=res://*/models.censusmodel.csdl|res://*/models.censusmodel.ssdl|res://*/models.censusmodel.msl;             provider=system.data.sqlclient;provider connection string='data source=stargate\dwcreports;             initial catalog=census;persist security info=false;             user id=***;password=***;             multipleactiveresultsets=true;app=entityframework'"            providername="system.data.entityclient" /> 

any great! thanks!

here stack trace:

[sqlexception (0x80131904): network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)]
system.data.sqlclient.sqlinternalconnectiontds..ctor(dbconnectionpoolidentity identity, sqlconnectionstring connectionoptions, sqlcredential credential, object providerinfo, string newpassword, securestring newsecurepassword, boolean redirecteduserinstance, sqlconnectionstring userconnectionoptions, sessiondata reconnectsessiondata, dbconnectionpool pool, string accesstoken, boolean applytransientfaulthandling) +970
system.data.sqlclient.sqlconnectionfactory.createconnection(dbconnectionoptions options, dbconnectionpoolkey poolkey, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningconnection, dbconnectionoptions useroptions) +802
system.data.providerbase.dbconnectionfactory.createpooledconnection(dbconnectionpool pool, dbconnection owningobject, dbconnectionoptions options, dbconnectionpoolkey poolkey, dbconnectionoptions useroptions) +38
system.data.providerbase.dbconnectionpool.createobject(dbconnection owningobject, dbconnectionoptions useroptions, dbconnectioninternal oldconnection) +682
system.data.providerbase.dbconnectionpool.usercreaterequest(dbconnection owningobject, dbconnectionoptions useroptions, dbconnectioninternal oldconnection) +89
system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, uint32 waitformultipleobjectstimeout, boolean allowcreate, boolean onlyonecheckconnection, dbconnectionoptions useroptions, dbconnectioninternal& connection) +426
system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, taskcompletionsource1 retry, dbconnectionoptions useroptions, dbconnectioninternal& connection) +78
system.data.providerbase.dbconnectionfactory.trygetconnection(dbconnection owningconnection, taskcompletionsource
1 retry, dbconnectionoptions useroptions, dbconnectioninternal oldconnection, dbconnectioninternal& connection) +191
system.data.providerbase.dbconnectioninternal.tryopenconnectioninternal(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource1 retry, dbconnectionoptions useroptions) +154
system.data.providerbase.dbconnectionclosed.tryopenconnection(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource
1 retry, dbconnectionoptions useroptions) +21
system.data.sqlclient.sqlconnection.tryopeninner(taskcompletionsource1 retry) +141
system.data.sqlclient.sqlconnection.tryopen(taskcompletionsource
1 retry) +362 system.data.sqlclient.sqlconnection.open() +96
system.data.entityclient.entityconnection.openstoreconnectionif(boolean opencondition, dbconnection storeconnectiontoopen, dbconnection originalconnection, string exceptioncode, string attemptedoperation, boolean& closestoreconnectiononfailure) +41

[entityexception: underlying provider failed on open.]
system.data.entityclient.entityconnection.openstoreconnectionif(boolean opencondition, dbconnection storeconnectiontoopen, dbconnection originalconnection, string exceptioncode, string attemptedoperation, boolean& closestoreconnectiononfailure) +206
system.data.entityclient.entityconnection.open() +104
system.data.objects.objectcontext.ensureconnection() +75
system.data.objects.objectquery1.getresults(nullable1 formergeoption) +41
system.data.objects.objectquery1.system.collections.generic.ienumerable<t>.getenumerator() +36 system.linq.enumerable.firstordefault(ienumerable1 source) +109 system.data.objects.elinq.<>c__111.<getelementfunction>b__11_1(ienumerable1 sequence) +41
system.data.objects.elinq.objectqueryprovider.executesingle(ienumerable1 query, expression queryroot) +59
system.data.objects.elinq.objectqueryprovider.system.linq.iqueryprovider.execute(expression expression) +134
system.data.entity.internal.linq.dbqueryprovider.execute(expression expression) +60 system.linq.queryable.firstordefault(iqueryable
1 source, expression1 predicate) +249
custommembershipprovider.getdbuser(censusentities db, string username) in c:\applications\development\pastoralreports\models\custommembershipprovider.cs:317 custommembershipprovider.validateuser(string username, string password) in c:\applications\development\pastoralreports\models\custommembershipprovider.cs:469 system.web.security.membership.validateuser(string username, string password) +26 census.controllers.rootcontroller.logon(logonmodel model, string returnurl) in c:\applications\development\pastoralreports\controllers\rootcontroller.cs:28 lambda_method(closure , controllerbase , object[] ) +147
system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +14
system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary
2 parameters) +194
system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary2 parameters) +27
system.web.mvc.async.<>c__displayclass42.<begininvokesynchronousactionmethod>b__41() +28 system.web.mvc.async.<>c__displayclass8
1.b__7(iasyncresult _) +10 system.web.mvc.async.wrappedasyncresult1.end() +50 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) +32
system.web.mvc.async.<>c__displayclass39.<begininvokeactionmethodwithfilters>b__33() +58 system.web.mvc.async.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() +225 system.web.mvc.async.<>c__displayclass4f.<invokeactionmethodfilterasynchronously>b__49() +225 system.web.mvc.async.<>c__displayclass37.<begininvokeactionmethodwithfilters>b__36(iasyncresult asyncresult) +10 system.web.mvc.async.wrappedasyncresult
1.end() +50 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethodwithfilters(iasyncresult asyncresult) +34
system.web.mvc.async.<>c__displayclass2a.b__20() +23 system.web.mvc.async.<>c__displayclass25.b__22(iasyncresult asyncresult) +99 system.web.mvc.async.wrappedasyncresult1.end() +50 system.web.mvc.async.asynccontrolleractioninvoker.endinvokeaction(iasyncresult asyncresult) +27
system.web.mvc.<>c__displayclass1d.<beginexecutecore>b__18(iasyncresult asyncresult) +14
system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +16 system.web.mvc.async.wrappedasyncresult
1.end() +50
system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +36 system.web.mvc.async.<>c__displayclass4.b__3(iasyncresult ar) +16 system.web.mvc.async.wrappedasyncresult1.end() +50
system.web.mvc.controller.endexecute(iasyncresult asyncresult) +26
system.web.mvc.controller.system.web.mvc.async.iasynccontroller.endexecute(iasyncresult asyncresult) +10
system.web.mvc.<>c__displayclass8.<beginprocessrequest>b__3(iasyncresult asyncresult) +25
system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +16 system.web.mvc.async.wrappedasyncresult
1.end() +50
system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +28 system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +9
system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9744261 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155

i found following techniques helpful:

  1. make sure database engine configured accept remote connections
 • start > programs > sql server 2005 > configuration tools > sql server surface area configuration • click on surface area configuration services , connections • select instance having problem > database engine > remote connections • enable local , remote connections • restart instance 
  1. check sql server service account
 • if not using domain account service account (for example if using network service), may want switch first before proceeding 
  1. if using named sql server instance, make sure using instance name in connection strings in asp.net web application
 • format needed specify database server machinename\instancename • check connection string • if sql server not configured on default port (1433) mention port in connection string 
  1. you may need create exception on firewall sql server instance , port using
 • start > run > firewall.cpl • click on exceptions tab • add sqlservr.exe (typically located in c:\program files (x86)\microsoft   sql server\mssql.x\mssql\binn), , port (default 1433) • check connection string 
  1. check if sql server services , running properly.

  2. check have connectivity sql server. note using connect: machine name, domain name or ip address? use when checking connectivity. example if using myserver

 • start > run > cmd • netstat -ano| findstr 1433 • telnet myserver 1433 • ping myserver 
  1. enable tcp/ip in sql server configuration
 • go programs >> microsoft sql server 2008 >> configuration tools >> sql server configuration manager >> select tcp/ip • right click on tcp/ip >> click on enable • must restart sql server services changes take effect. 
  1. configure sql server port no.
 • open "sql server configuration manager" • click on "sql server network configuration" , click on "protocols name" • right click on "tcp/ip" (make sure enabled) click on properties • select "ip addresses" tab -and- go last entry "ip all" • enter "tcp port" 1433. 

Comments