c# - Incorrect syntax near '('. Connection to database with entity framework -


i have asp.net mvc app works on local server. when i'm deploying windows server 2008 standard in iis (v7.0) app running property (i can see panel log in), when want log in, have such error. have page contact , when want run have same error.
add model.edmx using ado.net entity data model.

the code simple:

in controller:

private importentities entity = new importentities(); public actionresult contact()     {         var dane = entity.contact.firstordefault();         return view("contact",dane);     } 

connection string in web.config:

<add name="importentities" connectionstring="metadata=res://*/models.model.csdl|res://*/models.model.ssdl|res://*/models.model.msl;  provider=system.data.sqlclient;  provider connection string=&quot;data source=aaa\aaa;       initial catalog=database_name;       integrated security=true;       multipleactiveresultsets=true;       app=entityframework&quot;"  providername="system.data.entityclient" /> 

the error:

server error in '/myapp' application. line 1: incorrect syntax near '('.  description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.   exception details: system.data.sqlclient.sqlexception: line 1: incorrect syntax near '('.  source error:  unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below.    stack trace:  [sqlexception (0x80131904): line 1: incorrect syntax near '('.]    system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction) +1767866    system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction) +5352418    system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobject stateobj, boolean callerhasconnectionlock, boolean asyncclose) +244    system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready) +1691    system.data.sqlclient.sqldatareader.tryconsumemetadata() +61    system.data.sqlclient.sqldatareader.get_metadata() +90    system.data.sqlclient.sqlcommand.finishexecutereader(sqldatareader ds, runbehavior runbehavior, string resetoptionsstring) +365    system.data.sqlclient.sqlcommand.runexecutereadertds(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, boolean async, int32 timeout, task& task, boolean asyncwrite, sqldatareader ds) +1406    system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method, taskcompletionsource`1 completion, int32 timeout, task& task, boolean asyncwrite) +177    system.data.sqlclient.sqlcommand.runexecutereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream, string method) +53    system.data.sqlclient.sqlcommand.executereader(commandbehavior behavior, string method) +134    system.data.sqlclient.sqlcommand.executedbdatareader(commandbehavior behavior) +41    system.data.common.dbcommand.executereader(commandbehavior behavior) +10    system.data.entityclient.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior) +437  [entitycommandexecutionexception: error occurred while executing command definition. see inner exception details.]    system.data.entityclient.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior) +507    system.data.objects.internal.objectqueryexecutionplan.execute(objectcontext context, objectparametercollection parametervalues) +730    system.data.objects.objectquery`1.getresults(nullable`1 formergeoption) +131    system.data.objects.objectquery`1.system.collections.generic.ienumerable<t>.getenumerator() +36    system.linq.enumerable.firstordefault(ienumerable`1 source) +152    system.data.objects.elinq.objectqueryprovider.<getelementfunction>b__1(ienumerable`1 sequence) +41    system.data.objects.elinq.objectqueryprovider.executesingle(ienumerable`1 query, expression queryroot) +59    system.data.objects.elinq.objectqueryprovider.system.linq.iqueryprovider.execute(expression expression) +133    system.data.entity.internal.linq.dbqueryprovider.execute(expression expression) +87    system.linq.queryable.firstordefault(iqueryable`1 source) +251    myapp.controllers.homecontroller.contact() in c:\users\mon\documents\visual studio 2013\projects\myapp\myapp\controllers\homecontroller.cs:39    lambda_method(closure , controllerbase , object[] ) +62    system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +14    system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +182    system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +27    system.web.mvc.async.<>c__displayclass42.<begininvokesynchronousactionmethod>b__41() +28    system.web.mvc.async.<>c__displayclass8`1.<beginsynchronous>b__7(iasyncresult _) +10    system.web.mvc.async.wrappedasyncresult`1.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__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.<begininvokeaction>b__20() +24    system.web.mvc.async.<>c__displayclass25.<begininvokeaction>b__22(iasyncresult asyncresult) +99    system.web.mvc.async.wrappedasyncresult`1.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) +23    system.web.mvc.async.wrappedasyncresult`1.end() +55    system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +39    system.web.mvc.async.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar) +23    system.web.mvc.async.wrappedasyncresult`1.end() +55    system.web.mvc.controller.endexecute(iasyncresult asyncresult) +29    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) +23    system.web.mvc.async.wrappedasyncresult`1.end() +55    system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +31    system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +9    system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9514928    system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155    -------------------------------------------------------------------------------- version information: microsoft .net framework version:4.0.30319; asp.net version:4.0.30319.18446  

what don't understand: moment when app use string connection '('? can't install additional programs debug on server , check wrong.

do have ideas , wrong?

======
in model.edmx -> model.tt -> contact.cs

namespace myapp.models {     using system;     using system.collections.generic;      public partial class contact     {         public int id { get; set; }         public string phone { get; set; }         public string email { get; set; }         public string address { get; set; }         public string page { get; set; }     } } 

======
found sql query use app @paul_zahra help.

select top (1)  [c].[id] [id],  [c].[phone] [phone],  [c].[mail] [mail],  [c].[address] [address],  [c].[page] [page] [dbo].[contact] [c] 

now can see have problem first line. remember shouldn't have (1), 1. know how change it?

it caused 'sharing' context... try this... (it's best use unit of work approach creating , consuming db context unless know doing context , willing micro manage it)...

public actionresult contact() {     contact dane = null;      using (importentities ctx = new importentities())     {         ctx.connection.open();          dane = ctx.contact.firstordefault()          ctx.connection.close();     }      return view("contact",dane); } 

edit:

your issue stemming dbproviderinfo.providermanifesttoken; "a string identifies version of database server being used. example, sql server provider uses string "2008" sql server 2008. cannot null may empty."

are local (works ok) , server versions of sql server same? guess not.

the token specified in ssdl. see post interesting insights pretty big problem ef some


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -