Note that there are some explanatory texts on larger screens.

plurals
  1. POTPT and foreign key issue
    primarykey
    data
    text
    <p>I have a problem with TPT inheritance + foreign key. I'm working on a web application with multi language support, including translating dynamic content. Here's my tables:</p> <pre><code>Language ============= Id, Name ProcessingAgent ==================== Id, some other fields LocalizedProcessingAgent ========================================================= LocalizedProcessingAgentId, Name, Description, LanguageId </code></pre> <p>As you already guessed, I moved the columns which should be translated from <code>ProcessingAgent</code> to <code>LocalizedProcessingAgent</code>. On EF side, I made a TPT inheritance, so <code>ProcessingAgent</code> is a base class of <code>LocalizedProcessingAgent</code>. I'm new to EF, this is my first project I moved on and one of it's strange behavior really confuses me. When I generate EF classes from DB, <code>LocalizedProcessingAgent</code> has a Navigation Property Language (Because of <code>LanguageId</code>). The problem is that <code>Language</code> property is null after I query the db:</p> <pre><code>LocalizedProcessingAgentRecord l = db.ProcessingAgents .OfType&lt;LocalizedProcessingAgentRecord&gt;().First(p =&gt; p.Id == 1); //l.Language is null </code></pre> <p>So the foreign key Navigation Property is not filled for some reason, I don't know why. This happens only when I query derived entities, in this case <code>LocalizedProcessingAgentRecord</code>. Any ideas?</p> <p>here's EF xml markup: <a href="http://dl.dropbox.com/u/3055964/ef.xml" rel="nofollow noreferrer">http://dl.dropbox.com/u/3055964/ef.xml</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload