This article show you how you can remove "Server-generated keys and server-generated values are not supported by SQL Server Compact" the specified error.
This error occur when you try to save the data in an SQL Server Compact database the above error occur. As all we know that SQL Compact does not support IDENTITY keys when used with Entity Framework, since the SQL Compact engine only supports a single statement per batch.
So here is the solution if you are trying to save the record.
- Don't create identity column in your table.
- Now just make varchar or nvarchar date type for id column and make it primery key.
- Now add some unique value in id column like GUI id. Here is the sample code.
FileList _objfilelist = new FileList();
_objfilelist.Id
= Guid.NewGuid().ToString();
|
This comment has been removed by the author.
ReplyDeleteThis is not an issue with the latest Entity Framework 6.x SQL Server Compact providers (for 3.5 and 4.0)
ReplyDeleteHi Erik thanks for your comment. I have posted this article for those who are using Entity Framework lower version then 6.x.
Delete