UnitTest reports SQL error - data type not found
I am using this code:
using (var unitOfWork = this.unitOfWorkFactory.Create())
{
var tagParam = new SqlParameter
{
ParameterName = "@tagList",
SqlDbType = System.Data.SqlDbType.Structured,
Value = tags.ToTVP(),
TypeName = "[dbo].[TagList]"
};
unitOfWork.Context.Database.ExecuteSqlCommand("exec sp_InsertTagList @tagList", tagParam);
// unitOfWork.Context.Database.ExecuteSqlCommand("INSERT INTO dbo.Tags SELECT Name FROM @tagList", tagParam);
}
ToTvp
is just an extension method that does it DataTable
for me from a list of items.
I am getting this error:
Test method InspiredBlog.UnitTests.UnitTest1.TestMethod1 threw exception: System.Data.SqlClient.SqlException: column, parameter or variable @tagList .: Cannot find data type dbo.TagList.
I have created a table type in my database.
CREATE TYPE TagList AS TABLE
(
Name VARCHAR(MAX)
)
GO
I don't know why this error is being returned!
I can easily create a SQL query and execute in SSMS
+3
source to share
No one has answered this question yet
Check out similar questions: