问题
I'm trying to implement nested sets in my database model. To make it easy to use I would like to create stored procedures for insert/update/delete operations on my tree nodes to keep my tree in a valid state.
Is it possible to create mapping of the stored procedures in the current version of code-first model? I mean that my stored procedures will be called when for example, new entity will be added to the dbcontext.
回答1:
Code First in Entity Framework does not support Stored Procedure by default. As there is no designer we cannot even map our stored procs to the entity. There are a many scenario we have seen where we are bound to use stored procedure for any database modifications (insert/update/delete).
You can use below links, and/or google your question to find more solutions.
Using Entity Framework Code First with Stored Procedures AND Code First 4.1 : Using Stored Procedure to Insert Data
来源:https://stackoverflow.com/questions/7664449/ef-code-first-mapping-stored-procedures