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

时间:2015-05-13 14:33:39

标签: entity-framework entity-framework-5

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

  

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

内部异常中没有任何内容。这是违规函数,我无法再访问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

InnerException:

1 个答案:

答案 0 :(得分:0)

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

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