System.Data.SqlClient.SqlException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Table-valued parameter 1 ("@DataTable"), row 0, column 0: Data type 0xF3 (user-defined table type) has a non-zero length database name specified. Database name is not allowed with a table-valued parameter, only schema name and type name are valid.
When using
SqlCommandBuilder.DeriveParameters()which callsSqlCommand.DeriveParameters()the type name for the TVP in the derived parameters includes the database name which causesExecuteNonQuery()to fail with the following exception:In depth write-up and repro project here: ssa3512/DotNet_GetStoredProcCommand_TVP_Repro
https://github.com/dotnet/corefx/blob/875c9842c94fdf3885a7cd28497d492bdd584543/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs#L2212-L2214