【问题标题】:Calling Stored Procedures using Reverse POCO Generator使用反向 POCO 生成器调用存储过程
【发布时间】:2017-06-23 09:33:13
【问题描述】:

我有一个反向 POCO 生成器,可以从我的数据库中带入模型。我添加了一个存储过程,但在任何地方都找不到它,也不知道如何使用实体框架调用它。

我在 .tt 配置文件中设置了 IncludeStoredProcedures = true;IncludeTableValuedFunctions = true;。点击保存后控制台中没有错误或警告,存储过程配置如下:

// Stored Procedures ******************************************************************************************************************
    // Use the following regex filters to include or exclude stored procedures
    StoredProcedureFilterExclude = null;
    StoredProcedureFilterInclude = null;

    // Filtering of stored procedures using a function. This can be used in conjunction with the Regex's above.
    // Regex are used first to filter the list down, then this function is run last.
    // Return true to include the stored procedure, return false to exclude it.
    StoredProcedureFilter = (StoredProcedure sp) =>
    {
        // Example: Exclude any stored procedure in dbo schema with "order" in its name.
        //if(sp.Schema.Equals("dbo", StringComparison.InvariantCultureIgnoreCase) && sp.NameHumanCase.ToLowerInvariant().Contains("order"))
        //    return false;

        return true;
    };

我从this question 的理解是,因为我的存储过程没有返回任何数据,而是完成了插入,所以它不会与 POCO 一起传输。是对的吗?如果是这样,有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: c# sql-server stored-procedures ef-code-first


    【解决方案1】:

    我也有同样的问题,对我来说,我通过在存储过程顶部插入SET FMTONLY OFF 来解决这个问题(就在SET NOCOUNT ON 之后)

    【讨论】:

      猜你喜欢
      • 2016-07-19
      • 2019-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-27
      • 2014-08-10
      • 2012-01-03
      • 2011-11-16
      相关资源
      最近更新 更多