views:

49

answers:

1

Hi,

I have an existing database containing an article and a blog table. These have common columns such as title, author repeated in the two tables. I want to utilise entity framework to create a Content entity that pulls in the common properties so i can inherit the Content entity in the Article and Blog entity.

The idea being that I can say ok just get me all the content on the site in the last 10 days, i dont care whether its a blog or article. Then when i need to actually fetch an article ill go get the specific entity.

I have set up a content entity base and pulled in all the common blog and goal properties. Problem is what im trying to say in Contents. Ive got TWO mappings one to blog table and one to article table and EF complains that it cant work out which one to goto. I was hoping to add conditions to do this but if i add a blog specific condition (thats not listed in my base class) it complains it cant find the mapping.

I spose my first question is am I looking at this totally backwards in order to make my Contents entity get data from article table and blog table?

Thanks

Phil

Edit : Adding model and db schemas

alt text alt text

A: 

I'm not familiar with Entity but could you create a view in the database which contains all of the common data plus an extra key which identifies the record as either a blog or article.

You could then add the view to your Entity model, use that to fulfill your "get content from last 10 days" use case, and then when you need further detail, use the extra key you added to the view to determine whether you need to go to the blog or article entities. I know this isn't as clean and tidy as you want, but it may do the job.

hermiod