This one was a hard one to guess. But it's something like:

C#:
  1. DbConnection conn = Entities.Connection;
  2. DbCommand cmd = conn.CreateCommand();
  3.  
  4. string spname= "DoSomething";
  5. string entities = "Entities";
  6.  
  7. cmd.CommandType = CommandType.StoredProcedure;
  8. cmd.CommandText = string.Format("{0}.{1}", entities, spname);

You need to go to the edmx file, right click, add -> function. The tricky part on this was guessing the Entities.DoSomething name for the stored procedure. Nuno did the guessing part.

Related Posts

One Response to “How to invoke/run Stored Procedures on the Entity Framework”

  1. Pedro Santos Says:

    Another (easier) way is to create a dbml file and register there the stored procedures. You’ll then be able to use them on a data context class.