SQL Compact does not support IDENTITY keys when used with Entity Framework, since the SQL Compact engine only supports a single statement per batch.
This can be solved in various ways:
You can have all your primary keys be of type uniqueidentifier, and assign the NewGuid() value to the object upon creation:
Employee employee = new Employee();
employee.Id = Guid.NewGuid();
Or you can create an extension method as described here, noting the limitations of this approach.
1 comment:
FYI - I think the updated link for the extension method is http://enigmadomain.wordpress.com/2010/01/06/sql-compact-identity-columns-and-entity-framework/
Post a Comment