Can't insert entity into database

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
talert
Posts: 2
Joined: Sat 31 Oct 2009 13:48
Contact:

Can't insert entity into database

Post by talert » Sat 31 Oct 2009 14:07

Hi, I installed dotConnect for SQlite 2.60 beta then created DataContext with Entity Developer for dotconnect. In my table I have one autoincremented field.
When I tried to insert value on it I got System.InvalidOperationException.
Please tell me what I do wrong. Thanks.

table:
CREATE TABLE [trigger] (
[id] integer PRIMARY KEY AUTOINCREMENT NOT NULL,
[name] text NOT NULL )
entity:

Code: Select all

  [Table(Name = @"trigger")]
    public partial class Trigger : INotifyPropertyChanging, INotifyPropertyChanged    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private long _Id;

        private string _Name;

      
    
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnIdChanging(long value);
        partial void OnIdChanged();
        partial void OnNameChanging(string value);
        partial void OnNameChanged();
       #endregion

        public Trigger()
        {
            OnCreated();
        }

        [Column(Name = @"id", Storage = "_Id", CanBeNull = false, DbType = "integer NOT NULL", IsDbGenerated = true, IsPrimaryKey = true)]
        public long Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                if (this._Id != value)
                {
                    this.OnIdChanging(value);
                    this.SendPropertyChanging();
                    this._Id = value;
                    this.SendPropertyChanged("Id");
                    this.OnIdChanged();
                }
            }
        }

        [Column(Name = @"name", Storage = "_Name", CanBeNull = false, DbType = "text NOT NULL")]
        public string Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                if (this._Name != value)
                {
                    this.OnNameChanging(value);
                    this.SendPropertyChanging();
                    this._Name = value;
                    this.SendPropertyChanged("Name");
                    this.OnNameChanged();
                }
            }
        }
    }
}
How I use it:

Code: Select all

            using (var connector = new StorageConnector(connString))
            {
                var trigger = new Trigger
                             {
                                 Name = "test"
                             };

                connector.Triggers.InsertOnSubmit(trigger);

                connector.SubmitChanges();
            }
exception:
System.InvalidOperationException: Cannot refresh Entity. Record does not exist.
at Devart.Data.SQLite.Linq.Provider.SQLiteDataProvider.GetAutoSyncValues(MetaType type, IDbCommand dbCommand, IList`1 autoSyncFields, IList`1 autoSyncParameters, IList`1 keyFields, IList`1 keyParameters)
at Devart.Data.Linq.v.b(MetaType A_0, q A_1, Boolean A_2)
at Devart.Data.Linq.f.a(b A_0, Object A_1, ModifiedMemberInfo[] A_2, Boolean A_3)
at Devart.Data.Linq.k.a(DataContext A_0, ConflictMode A_1)
at Devart.Data.Linq.k.b(DataContext A_0, ConflictMode A_1)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Devart.Data.Linq.DataContext.SubmitChanges()
at StorageConnector.SubmitChanges() in line 16

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 03 Nov 2009 11:16

Thank you for the report, I have reproduced the problem.
I will let you know about the results of our investigation.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 16 Nov 2009 13:17

We have fixed the problem. The fix will be available in the nearest build.

talert
Posts: 2
Joined: Sat 31 Oct 2009 13:48
Contact:

Post by talert » Mon 16 Nov 2009 18:47

Thanks, this fix will make my life easier. Could you tell when a new build will be available for download?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 18 Nov 2009 08:47

The new build will be available today or tomorrow.

Post Reply