简体   繁体   中英

Add stored procedure to entity framework model (.edmx) without refreshing existing entities

I have a stored procedure in development environment that I want to add to EF data model (.edmx) and call it in my code through a method wrapper that EF creates.

Our development environment is not 100% in sync with production one so when I try adding the stored procedure deployed to development environment using "Update Model From Database" menu option all existing entities in the model get refreshed and extra properties are added to some of them.

I am trying to find a way to add the stored procedure without refreshing existing entities in the model so I don't get development and production differences into it.

Any idea how to achieve this?

Update 1:

After looking around and trying different things I came to a conclusion that the easiest way to do this would be to update the model pointing at development environment and then pointing at production. If there are differences between them you would see errors in Visual Studio saying the property mapping is missing, all you have to do is to find those properties and remove them from the model.

or

You can do what @Jonathan Amend suggested which should work fine as well just a little bit more work.

Why don't you update your edmx from the development database server? If that's not an option, you can create an intermediary between development and production to hold your new stored proc. For example, you could create a new database project based on the schema of your production database, add your new stored proc, then deploy the database project to a new database. Update your edmx from that new database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM