Reputation: 37
i use EF + Function in EF + SP for sent and get value at sql 2008.
SP:
ALTER proc [dbo].[InsertIntoScore]
(
@DateReg datetime,
@stdLastName nvarchar(50),
@stdFirstName nvarchar(50),
@Description nvarchar(500),
@tvpScore ScoreType READONLY
)
AS
DECLARE @Id AS INT
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO Student(DateReg,stdLastName,stdFirstName,[Description])
VALUES (@DateReg,@stdLastName,@stdFirstName,@Description)
set @Id = SCOPE_IDENTITY()
insert tblScore(...)
Select ... FROM @tvpScore
COMMIT
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
END CATCH
TVP:
CREATE TYPE dbo.ScoreType AS TABLE ( ScoreID int, StudentID int, etc.... )
but in Add SP to EF Display this Error:
The model was generated with warnings or errors.
Please see the Error List for more details. These issues must be fixed before running your application.
Loading metadata from the database took 00:00:02.5618735.
Generating the model took 00:00:01.2346890.
Upvotes: 0
Views: 404
Reputation: 364249
Ef doesn't support TVP. You must call this stored procedure directly with ADO.NET.
Edti: You can vote for TVP support on Data UserVoice.
Upvotes: 3