Add a line
ctx.Log = Console.Out;
to your code and you find out that a generated SQL is smth. like
INSERT INTO [Person]([Name], [Address])
VALUES (@p0, @p1)
SELECT CONVERT(Int,SCOPE_IDENTITY()) AS [value]
It seems that ACE is not happy with the construct of 'INSERT INTO ... VALUES (@p0, @p1) SELECT CONVERT ...'.
It rather had the SQL ended at 'SELECT CONVERT' and therefore it requests a semicolon put there.
A remedy is quite simple. Remove a string IsDbGenerated=true from a Column attribute on Person.ID member, and take responsibility of generating a Primary Key in your code. Something like
class insertwithlinqmapping
{
static void Main()
{
string ConnectionString =
String.Concat("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\\db.accdb");
OleDbConnection connection = new OleDbConnection(ConnectionString);
DataContext ctx = new DataContext(connection);
ctx.Log = Console.Out;
Table<objtable> objs = ctx.GetTable<objtable>();
var newObj = new ObjTable();
newObj.ID = ((from obj in objs
select (int?) obj.ID).Max() ?? 0) + 1;
newObj.Field1 = string.Concat("Field 1, rec ", newObj.ID.ToString());
newObj.Field2 = string.Concat("Field 2, rec ", newObj.ID.ToString());
objs.InsertOnSubmit(newObj);
ctx.SubmitChanges();
}
}
[Table]
class ObjTable
{
[Column(IsPrimaryKey = true)]
public int ID {get; set;}
[Column]
public string Field1 {get; set;}
[Column]
public string Field2 {get; set;}
}
</objtable></objtable>