Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework, TPT Inheritance and Multi-Language support
    primarykey
    data
    text
    <p>I have this DB Structure:</p> <p><strong>Service</strong></p> <ul> <li>Id int PK</li> <li>CategoryId FK</li> <li>SomeOtherFields</li> </ul> <p><strong>LocalizedService</strong></p> <ul> <li>LocalizedServiceId PK</li> <li>LanguageId FK</li> <li>Name</li> <li>Description</li> </ul> <p>As you can see, I have a base table called Service, and a LocalizedService table in which I'm writing multilingual data, such as name and description which should be translated in different languages. I have linked both tables in EF designer using TPT inheritance. Service is a base class of LocalizedService. The problem is that, TPT requires both tables to have primary key, which wouldn't be a problem if I was working on 1 language, but I should translate service rows across 3 different languages. So only LocalizedServiceId shouldn't be unique, but a combination of LocalizedServiceId + LanguageId should be unique because I can not insert more than one language row into LocalizedService. For example, take a look at LocalizedService rows bellow:</p> <ul> <li>1, 1, SomeService, NULL &lt;-- Inserted</li> <li>2, 1, AnotherService, NULL &lt;-- Inserted</li> <li>2, 2, RussianTranslationService, NULL &lt;-- can not insert because LocalizedServiceId with value 2 already exists in the table.</li> </ul> <p>That's not a problem on DB side, I can create PK for multiple fields (for example, LocalizedServiceId and LanguageId both will be Primary Key), but in this case, EF designer throws errors saying: "Error 13 Error 75: Key usage is not valid. uPay.Data.Entities.LocalizedServiceRecord cannot define keys because one of its base classes (uPay.Data.Entities.ServiceRecord) defines keys. D:\Projects\uPay\uPay.Data.Entities\Entities.edmx 1531 9 uPay.Data.Entities". I really need a solution on this problem ASAP, your help will be very appreciated. </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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