Entity Framework will not show stored procedures
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.
- Go to your App.config and look for the
connectionStrings
entry (usually at the bottom). If you have more than 1 connection string, the one you want is the one your context uses.- Go to your edmx file and drill down to find the entities class.
- For example, if you have
MyDbModel.edmx
, then under that you'll haveMyDbModel.Context.tt
which in turn will containMyDbModel.Context.cs
. - In the
MyDbModel.Context.cs
file you will have a class that inherits fromDbContext
and the constructor will callbase("name=<your connection string name>")
<your connection string name>
is the one you are looking for in your app.config.
- Your connection string shows the user (Integrated security will mean the AD user that is logged in. This will only work if everyone who uses your program will have the correct DB access. That can be a risky assumption in a production environment)
- Go to SQL Management Studio and add this stored proc to the user's "Securables"
Go to SP in Sql Server Management Studio, right click on properties, go to permissions Set public to Execute.
The above could all be the answer it is a permissions issue, the above answers made me look at why and concluded this.
This may be because Entity Framework is signing on to the database with a user id that does not have permission to execute stored procedures.
To find out:
In your app.config or web.config file on your .NET project, check to see which user id
is accessing the database. You'll see it after connectionString
just after user id=
.
If it is different than the user id you used to write the stored procedure (i.e. in SQL), check with your database administrator to see if that user id in from your .NET (and consequently Entity Framework) has permission to execute stored procedures.