I am mapping an entity to insert to stored procedure like this:
modelBuilder
.Entity<Member>()
.MapToStoredProcedures(s =>
s.Insert(u => u.HasName("stp_insert_member")));
The insert works great and passes all parameters to the stored procedure when I save new member.
But what happens when I try to update a member (loading entity from db by id, changing it's properties, and saving again - what will issue the update statement) is I get an exception because it's looking for stored procedure named Member_Update
.
But for that (and for delete), I don't want to have stored procedures. I just want to execute a stored procedure for the insert statement.
Can I map EF to a stored procedure for just the insert action?
Sadly it's all or nothing.
Entity Framework - Documentation:
You cannot use a mixture of stored procedures and direct table access for a given entity (or entity hierarchy). The insert, update and delete operations must all use direct table access or stored procedures.