NOTE: I'm using EF 4.2 with Database First Method and DbContext. This is NOT code first.
I'm trying to get the DbContext t4 tempalate to generate Stored Proc methods. There seems to be functionality built-into it to do so (it maps to the base ObjectContext), but for some reason it stubbornly refuses to generate them. I'm thinking it might have something to do with the return type (which is a single int, not a model type), but i'm not sure.
Before anyone says it. Yes, i Know DbContext doesn't support Stored Procs, which is why t4 template uses the IObjectContextAdapter to convert it to an ObjectContext. This is built-in functionality.
In the past, the methods were just auto generated. I don't know why it's not now. The Function appears in the .edmx file. Any suggestions on how to solve this?
<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>
Your sample function shows stored procedure definition in SSDL but it doesn't show either function import in CSDL or function import mapping in MSL. Did you create function import in model browser for your stored procedure? I just tested DbContext Generator template with 10 different procedures returning entities, complex types, scalars and using input and output parameters and it generated method in context class for each of them (but they had to be mapped to function imports).