Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to determine the principal end of OR “Value cannot be null, parameter name 'key'”
    primarykey
    data
    text
    <p>I have tried almost everything from StackOverflow to prevent these errors. I have no idea what am I doing wrong. When I'm starting with some changes to remove one bug, the second appear and vice versa. I don't know if it connects to DB, or can it initialize DB, or cannot. It looks like my DB file is empty - I'm using SQLite and I want to use Code First mechanism of EF.</p> <p>My code</p> <pre><code>using System.Data.Entity; using ControlCenter; namespace ControlCenter { public class IncomingMessaggesContext: DbContext { public DbSet&lt;UnifiedPositionMessage&gt; UnifiedPositionMessages { get; set; } public DbSet&lt;MessageDescription&gt; MessageDescriptions { get; set; } static IncomingMessaggesContext() { Database.SetInitializer&lt;IncomingMessaggesContext&gt;(null); } } } using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace ControlCenter.CommunicationGateway { using System; using TrackingDevices.Positioning; public class UnifiedPositionMessage { public int Id { get; set; } public uint DeviceID { get; set; } public DateTime ReceiveTime { get; set; } public PositionBase DevicePosition { get; set; } public object UserPayload { get; set; } public int MessageDescriptionId { get; set; } [ForeignKey("Id")] [Required] public virtual MessageDescription MessageDescription { get; set; } } public class MessageDescription { public int Id { get; set; } public bool IsMessageValid { get; set; } public virtual UnifiedPositionMessage UnifiedPositionMessage { get; set; } } } </code></pre> <p>Calling DB</p> <pre><code>using (var db = new IncomingMessaggesContext() ) { var msgDesc = new MessageDescription() {IsMessageValid = true, Id = 0, UnifiedPositionMessage = e.Frame}; db.MessageDescriptions.Add(msgDesc); db.UnifiedPositionMessages.Add(e.Frame); db.SaveChanges(); } </code></pre> <p>And connection settings</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt; &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/configSections&gt; &lt;entityFramework&gt; &lt;connectionStrings&gt; &lt;add name="IncomingMessaggesContext" connectionString="Data Source=c:\temp\Messages.db;" providerName="System.Data.SQLite" /&gt; &lt;/connectionStrings&gt; &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /&gt; &lt;/entityFramework&gt; &lt;system.data&gt; &lt;DbProviderFactories&gt; &lt;add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /&gt; &lt;/DbProviderFactories&gt; &lt;/system.data&gt; &lt;/configuration&gt; </code></pre>
    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.
    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