Stored procedures and functions is not updating for Entity Model - c#

I work with database first Entity Framework & LINQ in Visual Studio 2013.
When i write stored procedures and change them, i used to update Entity Data Model from database by choosing stored procedure updating option.
It is weird that the 'import selected stored procedures and functions into the entity model' option comes disabled so I cannot choose stored procedures and functions for updating model anymore..
Can you please help me to find the problem?

You only have to import stored procedure and functions into the model when they're new. So when there are no new ones the option is disabled.
This doesn't mean that, as you seem to suspect, EF doesn't update existing stored procedures and functions. It does.

Related

Add only required stored procedures to EDMX

I have two newly created stored procedures in my database. I tried to import those two stored procedures by going to Model Browser -> Function Imports -> Update Model from Database -> Add (tab) -> Selecting the newly created stored procedures under Stored Procedures and Functions -> dbo and clicking Finish button.
Note: I have checked 'Import Selected Stored Procedures and functions into the entity model' option.
The above step helped in adding the required stored procedures into my model/edmx.
But the problem I am facing is, it is also updating the other tables where there are few changes to one of the table where few columns were deleted in some table. This table has nothing to do with the stored procedures that I am importing. But it is asking me to update that table as well even though I have selected only the stored procedures.
Can someone please help me out why is this checking other tables which are not related to my newly added stored procedures even though I have selected to import only those stored procedures? how can I avoid other changes which are not relevant to my stored procedures?

Entity Framework code first with complex oracle stored procedure

I am working on upgrading an ASP.Net Web Forms application to MVC + EF Web Application.
I am more or less clear about the MVC part but seems to be a bit stuck about the EF part.
Since its a upgrade so there already exists a DB with lot of stored procedures, functions and other things and I would like to keep them.
For EF Code First from DB is the prefered option as it generates the Model classes automatically.
I am struggling to conceptualize how this will actually work.
for example:
I have two tables Employee & Salary as
There is a stored procedure getEmployeeDetails which returns a cursor with properties from both tables.
I am not sure how to map this in DbContext as what I have read so far is that you can map stored procedure to a single mode and not two or more.
Can someone please suggest what can do done here and what will be the best option in terms or using EF code first with existing procedures.
Thanks!!!

Entity Framework Database First not bringing in functions

Im using vs2012 and have a project where I have an Entity Framework v4.4 model pointed at a Sql Server 2008R2 database. For a while I have been adding stored procs and functions to the database and using Update Model From Database to bring them into the model without any problems.
Recently another developer working on the project started having trouble adding new stored procs and functions - he is using VS2013. When he chooses Update Model From Database, new stored procs show up in the list of procs to add, but when Finish is pressed, they are not added to the model, and in fact if he chooses Update Model From Database again, they are still listed in the new stored procs to add. Same thing happens with new functions.
He was able to get around this by modifying the edmx file manually, but we don't like this solution.
We have looked on SO and seen messages regarding giving EXECUTE permission on the procs (which we have not had to do before this). We tried giving the Execute permission, but that didn't change anything - same behavior.
Any ideas?
The functions were all table based functions, which evidently are not imported in EF 4

call a stored procedure multiple select query in entity framework code first and then map it to model

I am working on a project using entity framework code first approach, I have a situation where I need to call a stored procedure which returns multiple table, hence I want to map the result to my model. please tell me if its possible to do it and if yes then how can i do it.
Code First currently only supports mapping to tables. This unfortunately means
that you can’t map Code First directly to stored procedures, views, or other database
objects. If you are letting Code First generate a database, there is no way to
create these artifacts in the database, other than manually adding them once Code
First has created the database. If you are mapping to an existing database, there
are some techniques you can use to get data from non-table database artifacts.
i am also facing the same problem and not able to get any solution, so i called stored procedure using ExecuteReader and then mapped it to models using autoMapper.
Let me know if you are looking for code

How to update only dirty fields in .NET entity framework when using stored procedures for insert,update,delete?

I use .NET entity framework and mapped my database tables to it. i used stored procedures for insert,update, delete.
then I used EntityDataSource in an ASP.NET application which updates a table.
I don't change all the fields of the entity. there are some fields left unused.
the problem is that when the EntityDataSource performs Update Command. It tries to update ALL fields in the entity. so unused fields receive wrong values.
Is There any simple solution using entity framework designer ?
for example can i use original values for non-modified fields?
Don't use a stored procedure.
Unfortunately that's the only answer I have. A SP expects to get the values it's putting in, you can't tell it to only call with some of the parameters filled in.
If you're just letting EF do the updates without a SP, it should be able to handle this more intelligently.

Categories