Code First Mapping to Insert/Update/Delete Stored Procedures

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
aldare666
Posts: 10
Joined: Wed 08 Oct 2014 11:31

Code First Mapping to Insert/Update/Delete Stored Procedures

Post by aldare666 » Wed 08 Oct 2014 11:49

Hello,

I am trying to use dotConnect for Oracle for Code First with existing Database (I am not planning to generate the DB layer from the code) My aim is to have pure c# classes mapped by fluent mapping to stored procedures for CUD operations. I already have fully working MSSQL solution and trying now to switch to dotConnect/ORACLE.

Here (http://forums.devart.com/viewtopic.php?t=28241) is information this should be possible, quote :
**************************
Now, with dotConnect for Oracle, you can use such new Entity Framework features as ... Code First Mapping to Insert/Update/Delete Stored Procedures ...
**************************

Well, this is usually done by calling the method MapToStoredProcedures in fluent mapping. But here I found it is not implemented?!! - http://forums.devart.com/viewtopic.php? ... res#p98859

So my question is : how do I map the stored procedures using CodeFirst if not with MapToStoredProcedures? Is there any documentation/example?

Thanks a lot!
Ales

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Code First Mapping to Insert/Update/Delete Stored Procedures

Post by Shalex » Mon 13 Oct 2014 11:04

aldare666 wrote:Here (http://forums.devart.com/viewtopic.php?t=28241) is information this should be possible, quote :
**************************
Now, with dotConnect for Oracle, you can use such new Entity Framework features as ... Code First Mapping to Insert/Update/Delete Stored Procedures ...
**************************
dotConnect for Oracle supports mapping of existing stored procedures to CUD operations in Code-First (via DbContext template): http://www.devart.com/dotconnect/oracle ... ngCUD.html.
aldare666 wrote:Well, this is usually done by calling the method MapToStoredProcedures in fluent mapping. But here I found it is not implemented?!! - http://forums.devart.com/viewtopic.php? ... res#p98859
Our provider doesn't support the functionality of creating stored procedures automatically (when stored procedures don't exist in the database before running the code).

aldare666
Posts: 10
Joined: Wed 08 Oct 2014 11:31

Re: Code First Mapping to Insert/Update/Delete Stored Procedures

Post by aldare666 » Tue 04 Nov 2014 12:48

Thank you for your answer and sorry for delayed reply.

I am not willing to create database from code, I just want to use code-first and use it for already existing database objects. When using this aproach, there is no need for any model in the solution and the objects are pure.

The only need is to create fluent mapping next to the objects. Reverse engineering of existing database to objects and mapping can be done by Entity Framework Power Tools.
Created mapping has to be able to say : use stored procedures for some or all CUD operations. This is done by MapToStoredProcedures call. Calling MapToStoredProcedures doesn't mean I will create database objects, although it might be possible, but that is not desired in my (and in almost any enterprise solution) case.

I have tried to do it this way, without any entity model and DBContext template. And to my surprise IT WORKS! Even for backloading of the newly created ID of C procedures returned by output cursor param. There seems to be some magic behind the scenes...

There are some other problems, I will create new forum threads for these.

Post Reply