문제

I have a database which was generated with EF code first. I have table inheritance.

Now, that I have the database created, I need to do another project in my solution. This projects perform some operations on database after a concrete time has elapsed. So from this project, which is a windows service, I want to use entity framework again, but now, as database is created, I want to used database first.

In this project I choose the database, and finally the model is created without problems (edmx file). But my problem comes now: The model is created but the inheritance is not done as EF cannot know it from database so I do it manually by modifying the model to say it that some tables inherits from a base one. I use aggregate inheritance from the model designer, or simply editing the properties for the derived tables and change the attribute base type.

After do it, the designer.cs from the edmx gets empty saying there is an error.

Is it possible to manually indicate from model the inheritance once the model has been generated from an existing database? How to do this?

도움이 되었습니까?

해결책

Why don't you use the same EF context code you did in the first project, but disable database initialization in the second. Something like this answer:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top