EF can't infer return schema from Stored Procedure selecting from a #temp table

后端 未结 4 1864
迷失自我
迷失自我 2020-11-27 03:02

Suppose the following:

CREATE PROCEDURE [MySPROC]
AS 
BEGIN

CREATE TABLE #tempSubset(
    [MyPrimaryKey] [bigint]  NOT NULL,
    [OtherColumn]  [int]     NO         


        
4条回答
  •  日久生厌
    2020-11-27 03:20

    Adding this to the top of the stored procedure definition:

    SET FMTONLY OFF
    allowed the model to infer the schema from the temporary table without issue. As a bonus, it doesn't require additional maintenance for a contract.

    Example:

    SET FMTONLY OFF
    
    CREATE TABLE #tempTable (
        ...
    )
    
    ...
    
    SELECT * FROM #tempTable 
    

提交回复
热议问题