title: Bulk insert with EF ExecuteStoreCommand not working, what is wrong?
body: <p>I am using SQL 2008 and EF
  I have following stored proc for bulk insert</p>
  
  <pre><code>CREATE Type [dbo].[xxx] as Table (
  [ErrorCode] [nvarchar](10),
  [ErrorMessage] [nvarchar](300),
  [FieldName] [nvarchar](50),
  [FieldLable] [nvarchar](300),
  )
  CREATE procedure dbo.InsertAll(@Records xxx READONLY)
  as
  begin
  
  insert into dbo.MyTable
      select * from @Records;
  end;
  go
  </code></pre>
  
  <p>I am passing a Datatable as parameter (Type=structured) that has multiple records
  This proc works when called using SQLCommand.ExecuteNonQuery, but does not do anything when called using contextObject.ExecuteStoreCommand. The return value = affected rows is always 0</p>
  
  <p>Whats wrong? are such procedures not supported with EF? I am not even getting any exception :(</p>
  
  <p>Update: After running SQL trace just realized the difference in the SQL statements being generated</p>
  
  <p>When using contextObject.ExecuteStoreCommand</p>
  
  <pre><code>declare @p3 dbo.xxx
  insert into @p3 values(N'M',N'ErrorMsg - 0',NULL,NULL)
  insert into @p3 values(N'M',N'ErrorMsg - 1',NULL,NULL)
  insert into @p3 values(N'M',N'ErrorMsg - 2',NULL,NULL)
  exec sp_executesql N'InsertAll',N'@Records [xxx]
  READONLY',@Records=@p3
  </code></pre>
  
  <p>When using SQLCommand.ExecuteNonQuery</p>
  
  <pre><code>declare @p1 dbo.xxx
  insert into @p1 values(N'M',N'ErrorMsg - 0',NULL,NULL)
  insert into @p1 values(N'M',N'ErrorMsg - 1',NULL,NULL)
  insert into @p1 values(N'M',N'ErrorMsg - 2',NULL,NULL)
  exec InsertAll @Records=@p1
  </code></pre>
  
  <p>How can I get contextObject.ExecuteStoreCommand to execute the same SQL stmt like SQLCommand.ExecuteNonQuery?</p>