2

I have a stored proc in my database which returns an integer. I added a Function Import to my model. This appears in the EDMX file:

 <Function Name="GetTotalEntityCount" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />

However, no method actually gets generated for this. It should be top level, right?

 using (MyContext context = new MyContext())
 {
     context.MyMethodShouldBeRightHere();
 }

Nothing appears in Intellisense, I've gone through the designer.cs file and there's nothing in there, and reflected the DLL...nothing. The code generator is just not generating any code to support this stored proc.

I added another table to my database and updated the model, and that came in, so the model will update, it's just specifically ignoring this stored proc.

I've tried everything I can think of, and consulted every resource I can find, and as near as I can tell, I'm doing everything right.

I'm using EF4, database-first. (I'm pretty sure on the version, anyway. This shows up in the generated file:

Runtime Version:4.0.30319.1

)

Deane
  • 8,269
  • 12
  • 58
  • 108
  • so have you updated the database from model (ticked the stored proc), gone to the model browser, seen the stored proc there, right clicked, add function import. have you done all of that? – RPM1984 Jan 14 '11 at 23:17
  • See the comment under Andiih's answer. – Deane Jan 14 '11 at 23:51
  • I have the same problem. the Scalar Function shows up in the Store section of the Model Browser under stored procedures but not in the Types Section. I tried to add function import but it doesn't show up int he Stored procedures dropdown. Here is [Answer](http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/92a3214b-a662-44d5-bed3-11eae9926be6/) from MSFT (pretty useless) for a similar question. Appreciate any help on this front. thanks – Bhuvan May 10 '11 at 20:04

1 Answers1

0

Do you see the GetTotalEntityCount in the model browser ? Assuming you do, right click it and choose Add Function Import and map it to a scalar type. (Assuming you've not done this step)

Andiih
  • 12,285
  • 10
  • 57
  • 88
  • No, now that you mention it, I don't see it in the model browser. All I see there are my tables. However, when I go to update the model from the database, the stored proc is no longer there, and it's in the XML file, so it must have come in. Do I have to do something special to see it? If I right-click and say "Add > Function Import..", the stored proc is in the dropdown list. – Deane Jan 14 '11 at 23:51