entity framework - Connection string not working with MySQL -
i creating rest api
using mysql db
in visual studio 2015 in asp.net mvc 4.5
. have done each , every step in needed run api using mysql
, getting exception.
{"message":"an error has occurred.","exceptionmessage":"format of initialization string not conform specification starting @ index 121.","exceptiontype":"system.argumentexception","stacktrace":" @ system.data.common.dbconnectionoptions.getkeyvaluepair(string connectionstring, int32 currentposition, stringbuilder buffer, boolean useodbcrules, string& keyname, string& keyvalue)\r\n @ system.data.common.dbconnectionoptions.parseinternal(hashtable parsetable, string connectionstring, boolean buildchain, hashtable synonyms, boolean firstkey)\r\n @ system.data.common.dbconnectionoptions..ctor(string connectionstring, hashtable synonyms, boolean useodbcrules)\r\n @ system.data.common.dbconnectionstringbuilder.set_connectionstring(string value)\r\n @ mysql.data.mysqlclient.mysqlconnectionstringbuilder..ctor(string connstr)\r\n @ mysql.data.mysqlclient.mysqlconnection.set_connectionstring(string value)\r\n @ system.data.entity.infrastructure.interception.dbconnectiondispatcher.b__18(dbconnection t, dbconnectionpropertyinterceptioncontext
1 c)\r\n @ system.data.entity.infrastructure.interception.internaldispatcher
1.dispatch[ttarget,tinterceptioncontext](ttarget target, action2 operation, tinterceptioncontext interceptioncontext, action
3 executing, action3 executed)\r\n @ system.data.entity.infrastructure.interception.dbconnectiondispatcher.setconnectionstring(dbconnection connection, dbconnectionpropertyinterceptioncontext
1 interceptioncontext)\r\n @ system.data.entity.internal.lazyinternalconnection.initializefromconnectionstringsetting(connectionstringsettings appconfigconnection)\r\n @ system.data.entity.internal.lazyinternalconnection.tryinitializefromappconfig(string name, appconfig config)\r\n @ system.data.entity.internal.lazyinternalconnection.initialize()\r\n @ system.data.entity.internal.lazyinternalconnection.createobjectcontextfromconnectionmodel()\r\n @ system.data.entity.internal.lazyinternalcontext.initializecontext()\r\n @ system.data.entity.internal.internalcontext.getentitysetandbasetypefortype(type entitytype)\r\n @ system.data.entity.internal.linq.internalset1.initialize()\r\n @ system.data.entity.internal.linq.internalset
1.getenumerator()\r\n @ system.data.entity.infrastructure.dbquery1.system.collections.generic.ienumerable<tresult>.getenumerator()\r\n @ system.collections.generic.list
1..ctor(ienumerable1 collection)\r\n @ system.linq.enumerable.tolist[tsource](ienumerable
1 source)\r\n @ restwithmysql.controllers.productscontroller.get() in d:\work\dot net api\restwithmysql\restwithmysql\controllers\productscontroller.cs:line 19"}
i think there problem in connection string. have searched couldn't find exact solution.
<connectionstrings> <!--<add name="defaultconnection" connectionstring="data source=(localdb)\mssqllocaldb;attachdbfilename=|datadirectory|\aspnet-restwithmysql-20170911031521.mdf;initial catalog=aspnet-restwithmysql-20170911031521;integrated security=true" providername="system.data.sqlclient" />--> <add name="productentities" connectionstring="metadata=res://*/productsmodel.csdl|res://*/productsmodel.ssdl|res://*/productsmodel.msl;provider=mysql.data.mysqlclient;provider connection string=" server=localhost;user id=root;database=accurate_dev;integrated security=true;multipleactiveresultsets=true;app=entityframework" providername="mysql.data.mysqlclient"/> <!--<remove name="localmysqlserver" /><add name="localmysqlserver" connectionstring="" providername="mysql.data.mysqlclient" />--> </connectionstrings>
any highly appreciated.
strip down connection string bare minimum. add options , see causes fail. example integrated security=true
not going work mysql. need add password
instead.
form here: asp.net mvc 4 ef5 mysql
try closer this:
<add name="defaultconnection" providername="mysql.data.mysqlclient" connectionstring="data source=localhost;port=3306;initial catalog=api_db;user id=root;password=''"/>
Comments
Post a Comment