注意:我将 EF 4.2 与 Database First Method 和 DbContext 一起使用。这不是代码优先。
我正在尝试获取 DbContext t4 模板来生成存储过程方法。它似乎内置了这样做的功能(它映射到基本 ObjectContext),但由于某种原因它顽固地拒绝生成它们。我认为它可能与返回类型(它是单个 int,而不是模型类型)有关,但我不确定。
在任何人说之前。是的,我知道 DbContext 不支持存储过程,这就是 t4 模板使用 IObjectContextAdapter 将其转换为 ObjectContext 的原因。这是内置功能。
过去,这些方法只是自动生成的。我不知道为什么不是现在。函数出现在 .edmx 文件中。关于如何解决这个问题的任何建议?
<Function Name="pInsertMemberPayment" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="xMemberID" Type="int" Mode="In" />
<Parameter Name="xCardHolderName" Type="varchar" Mode="In" />
<Parameter Name="xBillingAddress" Type="varchar" Mode="In" />
<Parameter Name="xBillingCity" Type="varchar" Mode="In" />
<Parameter Name="xBillingState" Type="char" Mode="In" />
<Parameter Name="xBillingZip" Type="varchar" Mode="In" />
<Parameter Name="xAccountNumber" Type="varchar" Mode="In" />
<Parameter Name="xExpirationDate" Type="date" Mode="In" />
<Parameter Name="xRowCreatedSYSUserID" Type="int" Mode="In" />
<Parameter Name="xRowCreatedDateTime" Type="datetime2" Mode="In" />
<Parameter Name="xRowModifiedSYSUserID" Type="int" Mode="In" />
<Parameter Name="xRowModifiedDateTime" Type="datetime2" Mode="In" />
<Parameter Name="xMemberPaymentID" Type="int" Mode="InOut" />
</Function>