Friday, 8 August 2014

Error : Server-generated keys and server-generated values are not supported by SQL Server Compact

8/08/2014 - By Pranav Singh 3

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();


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This is not an issue with the latest Entity Framework 6.x SQL Server Compact providers (for 3.5 and 4.0)

    ReplyDelete
    Replies
    1. Hi Erik thanks for your comment. I have posted this article for those who are using Entity Framework lower version then 6.x.

      Delete

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top