Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Composite Key Entity Framework
    primarykey
    data
    text
    <p>Shortly, I want to create composite keys on my table remaining with the primary key in order to improve sql server search performance. The performance issue occurs on 200k data table whenever I search an entity without primary key (i.e a string of GUID). Assume that I have 3 classes </p> <pre><code>public class Device{ public int ID { get; set; } public string UDID { get; set; } public string ApplicationKey { get; set; } public string PlatformKey { get; set; } public ICollection&lt;NotificationMessageDevice&gt; DeviceMessages { get; set; } } public class NotificationMessageDevice { [Column(Order = 0), Key, ForeignKey("NotificationMessage")] public int NotificationMessage_ID { get; set; } [Column(Order = 1), Key, ForeignKey("Device")] public int Device_ID { get; set; } public virtual Device Device { get; set; } public virtual NotificationMessage NotificationMessage { get; set; } } public class NotificationMessage { public int ID { get; set; } public string Text { get; set; } public DateTime CreateDate { get; set; } } modelBuilder.Entity&lt;Device&gt;().HasKey(t =&gt; new { t.ID, t.ApplicationKey, t.PlatformKey, t.UDID }); </code></pre> <p>What the problem is that whenever I want to make ID , UDID , ApplicationKey and PlatformKey define as a Composite Key with modelBuilder it gives the following error.</p> <blockquote> <p>NotificationMessageDevice_Device_Target_NotificationMessageDevice_Device_Source: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical</p> </blockquote> <p>I think the problem is because the navigation property on NotificationMessageDevice is not able to recognize what the primary key is on Device table. How can I resolve this problem? In addition to this I will be glad if you share your experiences improving the search performance on Entity framework. Usually the performance issue occurs on whenever I use First method without primary keys.</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.
 

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