实体框架生成模型时发生错误

时间:2016-01-27 11:43:10

标签: entity-framework asp.net-mvc-5 entity-framework-4 entity-framework-6 entity-framework-5

  • 我的edmx中的表格很少(不超过20个)
  • 我的edmx中有很多存储过程列表(可能超过1k)。
  • EF版本5.0

每当我尝试从DB添加/更新模型时,它总会抛出此错误,任何人都可以帮我解决这个错误吗?

  

由于以下异常,无法生成模型:   'System.Data.Entity.Core.EntityCommandExecutionException:错误   执行命令定义时发生。看到内心   细节例外。 ---> System.Data.SqlClient.SqlException:The   传入请求的参数太多。服务器支持   最多2100个参数。减少参数数量并重新发送   请求。在   System.Data.SqlClient.SqlConnection.OnError(SqlException异常,   布尔值breakConnection,Action 1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction)at   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject   stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)at   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,   SqlCommand cmdHandler,SqlDataReader dataStream,   BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject   stateObj,布尔& dataReady)at   System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()at   System.Data.SqlClient.SqlDataReader.get_MetaData()at   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,   RunBehavior runBehavior,String resetOptionsString)at   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean   async,Int32超时,任务& task,Boolean asyncWrite,SqlDataReader   ds)at   System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String   方法,TaskCompletionSource 1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext
1 c)at   System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func 3操作,TInterceptionContext interceptionContext,   行动3 executing, Action 3已执行)   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(的DbCommand   命令,DbCommandInterceptionContext interceptionContext)at   System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(的CommandBehavior   行为)   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
  在   System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand   entityCommand,CommandBehavior行为)---内部异常结束

1 个答案:

答案 0 :(得分:0)

这种错误通常是由模型中的许多对象引起的(看起来就像所有程序一样)并且Entity Framework不够智能,无法使多个数据库往返。

您可以找到有关此问题的更多信息:https://social.msdn.microsoft.com/Forums/en-US/aafb63c4-61df-4d8d-9373-df78d6f7d686/entity-framework-vs-2012-designer-fails-calling-spexecutesql-with-too-many-parameters-when-updating?forum=adodotnetentityframework