[Updated problem description]
We have a bulk import process for which we were passing IEnumerable
as a Table Valued Parameter (TVP) to a St
The only possible error I could find in your code is the SqlParameter
's TypeName
. Yours is not fully qualified, I needed to include the schema, i.e. "dbo.".
I'm using EFCore 2.0.2 and EFCore.SqlServer 2.0.2
This is my code:
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("FieldId", typeof(int)));
table.Columns.Add(new DataColumn("Value", typeof(double)));
foreach (Value v in NewRows)
{
DataRow row = table.NewRow();
row["FieldId"] = v.FieldId;
row["Value"] = v.Value;
table.Rows.Add(row);
}
var param = new SqlParameter("@replacementValues", table) { TypeName = "dbo.CustomSqlType", SqlDbType = SqlDbType.Structured };
await _dbContext.Database.ExecuteSqlCommandAsync("EXEC dbo.UpdateValues @replacementValues", param);