Inserting an Entity into a SQL Compact 4 Table with an Identity Column Using LINQPad

advertisements

I'm trying to insert new records into a SQL CE 4 database with LINQPad and having problems with the identity problem of a table. Let's say I have this simple table for instance:

PEOPLE
Id int IDENTITY(1,1) NOT NULL,
Name nvarchar(100) NOT NULL

I may be doing things the wrong way but I tried this in LINQPad

People person = new Person { Name = "Bob" };
People.InsertOnSubmit(person);
SubmitChanges();

But I get a SqlCeException stating

"The colum cannot be modified. [ Column name = Id ]"

I can insert a record with SQL just fine, that works with no errors from SQL CE or its data provider and SQL CE sets the Id column for me which is what I'm wanting

INSERT INTO PEOPLE (Name) VALUES ('Bob');

Is there another step that I'm missing? I'm not even sure if its a LINQPad issue but thought I'd ask anyways since that's what I'm trying this code with right now.


What do you get if you run this in LinqPad

(from dm in this.Mapping.GetTable(typeof(People)).RowType.DataMembers
    select new  { dm.DbType, dm.Name, dm.IsPrimaryKey , dm.IsDbGenerated }
 ).Dump();

In particular, as I understand it, IsDbGenerated should be true for the id column.

I have a SQL CE 3.5 data file that I have used previously in LinqPad and looking at the SQL generated for inserts it does not mention id