Can EF6 generate my model objects from a ref cursor returned by an oracle stored procedure

让人想犯罪 __ 提交于 2020-01-16 05:47:05

问题


Can EF6 generate my model objects from a ref cursor returned by an oracle stored procedure??

So my current workplace is in the middle of a switch from using webforms to MVC5.

We would like to use EF6 and Oracle stored procedures. A lot of the models that we want to implement will be selecting data from multiple tables(our database is massive). We already have some stored procedures already as well.

I either need to be able to tell EF6 to map my models to the results of a stored procedure or explicitly tell EF6 which table each of my models attributes is coming from.

The other option would be to create oracle views for each model.

I've been googling around for a while and I'm having a hard time finding a way to accomplish what we need.

Before, when we used webforms, we were using our own custom DAL/ORM. But we would really like to switch to using Entity Framework.


回答1:


You have 2 fundamental choices here:

Code First:

Design your models, and "wire" them up to your procedures that you have defined manually.

http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

http://entityframework.codeplex.com/wikipage?title=Code%20First%20Insert%2fUpdate%2fDelete%20Stored%20Procedure%20Mapping

Database First:

Point the EF at your DB and models will be created for you using your schema. You can always call your custom procedures using Helper classes etc.. You would pass in the EF model and extract the attributes needed.

Personally, I prefer to code first simple POCO objects and wire them up as I see fit. This gives you the most flexibility however it can get out of hand if you don't lay down an architecture first and abide by some governing patterns.

As for performance for high volume systems, similar to Ruby-On-Rails boiler plate MVC approaches can get unwieldy as they grow. Using efficient procedures for CRUD will always win out over dynamic SQL.




回答2:


It seems what I was trying to accomplish isn't supported. EF6 only supports create/update/delete stored procedures. Hopefully we can figure out a standard way of using MVC5 with the oracle DB we already have in place.

Thank you T McKeown for your efforts, your links helped lead me to my conclusion.



来源:https://stackoverflow.com/questions/21636005/can-ef6-generate-my-model-objects-from-a-ref-cursor-returned-by-an-oracle-stored

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!