我正在创造一个 REST API
运用 MySQL DB
在 visual studio 2015 in asp.net mvc 4.5
。我已经完成了运行API所需的每一步 MySQL
,但我得到了这个例外。
{“消息”:“发生了错误。”,“ExceptionMessage”:“初始化字符串的格式不符合从索引121开始的规范。“,”ExceptionType“:”System.ArgumentException“,”StackTrace“:”at 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 definitions,Boolean useOdbcRules) )\ r \ n at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)\ r \ n at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(String connStr)\ r \ n at MySql.Data.MySqlClient.MySqlConnection System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__18中的.set_ConnectionString(String value)\ r \ n(DbConnection t,DbConnectionPropertyInterceptionContext
1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch [TTarget,TInterceptionContext](TTarget target,Action2 operation, TInterceptionContext interceptionContext, Action
3执行,动作3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext
1 interceptionContext)\ r \ n at 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.Interial.Conit上的System.Data.Entity.Internal.LazyInternalConnection.Initialize()\ r \ n,在System.Data.Entity.Inter.RazyInternalContext.InitializeContext()中的System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()\ r \ n \ r \ n在System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\ r \ n在System.Data.Entity.Internal.Linq.InternalSet中1.Initialize()\r\n at System.Data.Entity.Internal.Linq.InternalSet
1.GetEnumerator()\ r \ n在System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()\r\n at System.Collections.Generic.List
1..ctor(IEnumerable的1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable
1源代码)\ r \ n在D:\ Work \ DOT NET API \ RestWithMySQL \ RestWithMySQL \ Controllers \ ProductsController.cs中的RestWithMySQL.Controllers.ProductsController.Get():第19行“}
我认为我的连接字符串有问题。我搜索过它但找不到确切的解决方案。
<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>
任何帮助将受到高度赞赏。