title: EF4 Code First with existing DB and one to one/one to many on SAME type
body: <p>After countless hours I finally managed to get the fluent api settings to map our complex existing SQL DB to POCO classes. There is one thing which I do not get to work and I am wondering if it might not be supported.</p>
  
  <p>Class Power has:</p>
  
  <pre><code>List&lt;Transaction&gt; PowerTransactions;
  Transaction LastPowerTransaction;
  int PowerTransactionId;
  </code></pre>
  
  <p>Transactions is one to many where the Transaction Table has a FK pointing to Power.PowerID, that works fine.</p>
  
  <p>Power has column PowerTransactionId and  FK pointing to the TransactionId in the Transaction Table.</p>
  
  <p>I set in fluent API:</p>
  
  <p>Power has optional Last Transaction with required power</p>
  
  <pre><code>HasOptional(x =&gt; x.LastPowerTransaction).WithRequired(x =&gt; x.PowerLastPowerTransaction).Map(x =&gt;     x.MapKey("PowerTransactionId"));
  </code></pre>
  
  <p>Powers TransactionId is 123 and PowerID is 1, when selecting Power.LastPowertransaction I get the transaction with id 1 not 123.</p>
  
  <p>As the many to many does a select .. from PowerTransaction where PowerID=1, the One to One does the same thing instead of select .. from PowerTransaction where PowerID=123.</p>
  
  <p>What am I missing here ?</p>