This is the first time I used SQL Server ce to practice entitier framework. this error is reported for a simple insert operation. I checked msdn later and found it because I used the auto-increment field, in the Entity Framework, SQL Server ce does not support keys or values generated by the server.
The reason is as follows:
When used together with the Entity Framework, SQL Server compact has the following restrictions:
- When used together with the Entity Framework, SQL Server compact does not support entities with keys or values generated by the server.
When an Entity Framework is used, the entity key may be marked as generated by the server. In this way, the database can generate a key value when inserting or creating an object. In addition, zero or multiple attributes of an object can be marked as the value generated by the server. For more information, see the schema topic generated by storage in the Entity Framework documentation.
When used together with the Entity Framework, SQL Server compact does not support entities with server-generated keys or values, although the Entity Framework allows you to define entity types with server-generated keys or values. An "unsupported" exception occurs when processing an object with the value generated by the server.
- When SQL Server compact is used together with the Entity FrameworkSkipExpression. On the other hand, SQL Server compact supportsLimitAndTopExpression.
Paging query is used to support stateless paging (scrolling or window-based) through the query results ).
Msdn article: http://msdn.microsoft.com/zh-cn/library/cc835494 (V = SQL .100). aspx