I have been messing with this all morning, but I can't find the answer. I am trying to use EF to reference a stored procedures, but no matter what I try I cannot get it to show up in the model browser.
I have used the following steps to try to get the procedures into the modal:
add procedure to Entity model
right click on model and choose add new --> Function Import
Give it a name and select my procedure
generate a new complex collection (I have also tried using an entity, neither work)
I have done this many times, and I can see the function in the "function Imports" folder in the model, but it never shows up in the model, so I can't reference it.
I find I can reference the stored procedure directly (without the import) by doing the following:
DBEntities db = new DBEntities(); var test = db.gsp_GetGroups();
However, I cannot convert this to
IQueryable<T> without a big workaround.
Does anybody know what steps I'm missing to get this to add properly?
P.S. VS 2012, asp.net 4.0
Verify that the SQL log-in you are using to generate your EF model has permission to execute the stored procs you are trying to import.
connectionStringsentry (usually at the bottom). If you have more than 1 connection string, the one you want is the one your context uses.
MyDbModel.edmx, then under that you'll have
MyDbModel.Context.ttwhich in turn will contain
MyDbModel.Context.csfile you will have a class that inherits from
DbContextand the constructor will call
base("name=<your connection string name>")
<your connection string name>is the one you are looking for in your app.config.