I can't seem to figure out why I can't get my code below working. I confirmed that my DataTable has records when calling the stored procedure, however the actual table-valued parameter that arrives at my stored procedure has no records. (this was confirmed by logging a rowcount in the proc). Any ideas as to what might be my issue? I'm using EntityFrameworkCore 6.
public class MyDbContext : DbContext, IMyDbContext
{
public MyDbContext()
{
}
public MyDbContext(DbContextOptions<MyDbContext> options)
: base(options)
{
}
public int InsertStagingData(DataTable data)
{
var parameter = new SqlParameter("@TVP_StagingData", data)
{
TypeName = "dbo.dataType",
SqlDbType = SqlDbType.Structured
};
var response = this.Database.ExecuteSqlRaw("EXEC [dbo].[sp_InsertStagingData]", parameter);
return response;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}