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

Entity framework 数据实体添加范围退出工作,entity-framework,entity-framework-5,Entity Framework,Entity Framework 5,正如标题所示,我有一个小程序,在过去3个月里一直在生产中运行。上周,它开始在AddRange行出错,并显示以下错误消息: “消息=不支持关键字:'文件'。” 内部没有例外。这是一个有问题的函数,我无法再访问SaveChanges()行 private static void SaveToDB(List<MarketNew> inMarketNews) { proxy.MarketNews.AddRange(inMarketNews); proxy.SaveChan

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

“消息=不支持关键字:'文件'。”

内部没有例外。这是一个有问题的函数,我无法再访问
SaveChanges()

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

    proxy.MarketNews.AddRange(inMarketNews);
    proxy.SaveChanges();
}
private static void SaveToDB(MarketNews中的列表)
{
proxy.MarketNews.AddRange(在MarketNews中);
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
捕获到System.ArgumentException HResult=-2147024809 Message=不支持关键字:“文件”。 Source=System.Data 堆栈跟踪: 位于System.Data.Common.DbConnectionOptions.ParseInternal(哈希表parsetable、字符串connectionString、布尔构建链、哈希表同义词、布尔第一键) 位于System.Data.Common.DbConnectionOptions..ctor(字符串连接字符串、哈希表同义词、布尔useOdbcRules) 位于System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) 位于System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString,DbConnectionOptions previous) 位于System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey、DbConnectionPoolGroupOptions、DbConnectionOptions和userConnectionOptions) 位于System.Data.SqlClient.SqlConnection.ConnectionString_集合(DbConnectionPoolKey) 位于System.Data.SqlClient.SqlConnection.set_ConnectionString(字符串值) 在System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b_u18(DbConnection t,DbConnectionPropertyInterceptionContext`1c) 在System.Data.Entity.Infrastructure.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget,Action`2 operation,TInterceptionContext interceptionContext,Action`3 executing,Action`3 executed) 位于System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection连接,DbConnectionPropertyInterceptionContext`1 interceptionContext) 位于System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(字符串名称或连接字符串) 在System.Data.Entity.Internal.LazyInternalConnection.Initialize()中 在System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()中 在System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()中 位于System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext上下文) 在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()中 位于System.Data.Entity.Internal.InternalContext.Initialize()处 位于System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType) 位于System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 位于System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() 位于System.Data.Entity.Internal.Linq.InternalSet`1.AddRange(IEnumerable entities) 位于System.Data.Entity.DbSet`1.AddRange(IEnumerable`1 entities) 在e:\Tableau\Custom Utilities\MarketNews\GetMarketNews\GetMarketNews\GetMarketNews\Program.cs第195行的GetMarketNews.Program.SaveToDB(MarketNews中的列表'1)中
InnerException:

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


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

显示完整的例外情况您是否仅通过
AddRange
获得此错误?你也能通过正常的查询得到吗?非常感谢。即使在调试中,我也看不出连接字符串有任何错误。但是我注释掉了旧的连接并创建了一个新的连接字符串,一切都很好。因此,最后我很高兴听到:旧连接字符串和新连接字符串之间有什么区别?我看不到任何不同,字符串中没有“file”这个词。我不明白为什么会这样。我要把它记在小精灵的账上。