开发者

Can you do entity inheritance in EF on an entity that is mapped to stored procedures?

开发者 https://www.devze.com 2023-04-09 07:34 出处:网络
I have a question about inheritance in Entity Framework 4. We are using a database-first approach and would like to restructure our model to use inheritance. Here is a white board mock up of the hiera

I have a question about inheritance in Entity Framework 4. We are using a database-first approach and would like to restructure our model to use inheritance. Here is a white board mock up of the hierarchy we would like to use in our model.

Image 1

In case those scribbles are not very readable, it's something like this.

USER <- PROVIDER

USER <- VENDOR

PROVIDER <- EMPLOYEE

So USER is the base class for providers and vendors. And employee then inherits from provider.

I found a couple great articles describing Table-Per-Hierarchy inheritance and Table-Per-Type inheritance.

They s开发者_运维技巧eem simple enough but both ways require an entity to be mapped to a table or tables. What if you have an entity that is mapped entirely to stored procedures?

Image 2

Is it still possible to do inheritance in EF even if an entity is mapped to stored procedures? How would that look? What kinds of stored procedures would we need to have to accomplish this?

If it's possible we really just need pointed in the right direction.


I have searched and searched and finally arrived at the conclusion that it is not possible to do inheritance with entities that are mapped to stored procedures. So unless someone can prove otherwise, I'm marking this as the answer.


I am using a completely stored procedure mapped repository architecture in my MVC project. In that we are not using the entity framework, instead of that we use Microsoft Enterprise Library. We are using the methods from it. From my experience, The repository contains only methods for data manipulation using stored procedures. The Tables are mapped to Models. There are ViewModels which are custom Model classes for handling properties which are defined as custom in the project. There is one service layer to separate the Controllers and Repositories. So I think you can adopt the method of repository mapped entirely to stored procedures

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号