数据实体添加范围退出工作

Data Entities Add Range quit working

如标题所示,我有一个小程序已经 运行 在过去 3 个月中投入生产。上周它开始在 AddRange 行上出错,并显示以下错误消息:

"Message=Keyword not supported: 'file'."

内部异常中没有任何内容。这是有问题的功能,我无法再进入 SaveChanges() 行。

private static void SaveToDB(List<MarketNew> inMarketNews) 
{

    proxy.MarketNews.AddRange(inMarketNews);
    proxy.SaveChanges();
}

干杯 鲍勃

编辑- 如果我尝试一次手动添加一个,我仍然会收到以下异常。

System.ArgumentException was caught
HResult=-2147024809
Message=Keyword not supported: 'file'.
Source=System.Data
StackTrace:
   at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
   at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
   at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__18(DbConnection t, DbConnectionPropertyInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext)
   at System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()
   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)
   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.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Internal.Linq.InternalSet`1.AddRange(IEnumerable entities)
   at System.Data.Entity.DbSet`1.AddRange(IEnumerable`1 entities)
   at GetMarketNews.Program.SaveToDB(List`1 inMarketNews) in e:\Tableau\Custom Utilities\MarketNews\GetMarketNews\GetMarketNews\Program.cs:line 195

内部异常:

该异常表示您的连接字符串有问题。虽然程序本身可能几个月没有更改,但您能否确认配置文件(或者您设置的连接字符串)没有更改?

如果您仍然无法从这里找到它,我建议您在运行时检查连接字符串的值(例如在 AddRange 行上放置一个断点,然后查看 proxy.Database.ConnectionString)。我怀疑您会在连接字符串中找到 "file" 关键字。