【问题标题】:How to fix error 'Format of the initialization string does not conform to specification starting at index 100'如何修复错误“初始化字符串的格式不符合从索引 100 开始的规范”
【发布时间】:2023-04-10 16:11:01
【问题描述】:

这是我用于本地调试的连接字符串

connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=SFP;
initial catalog=POLLINATORS;
integrated security=True;
MultipleActiveResultSets=True;
App=EntityFramework"

部分堆栈跟踪:

在 System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions 的 System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, String& keyname, String& keyvalue)。 ParseInternal(IDictionary2 parsetable, String connectionString, IList1 validKeywords) 在 System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions..ctor(String connectionString, IList1 validKeywords) at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString) at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet1.Initialize() 在 System.Data.Entity.Internal.Linq。 InternalSet1.get_InternalContext() at System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider()

感谢您的帮助! ~苏珊~

【问题讨论】:

  • 该错误表明,在连接字符串的第 100 个字符处,连接字符串不再有效。您是否将其保存在 web.config 中的多行中?你不能那样做。

标签: entity-framework connection-string


【解决方案1】:

您在提供程序连接字符串中缺少右引号:

connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=SFP;
initial catalog=POLLINATORS;
integrated security=True;
MultipleActiveResultSets=True;
App=EntityFramework""

【讨论】:

  • 谢谢,效果很好。然而,它发现了另一个问题。我将打开另一个请求。非常感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2012-01-04
  • 2015-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多