Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:52:22+00:00 2026-06-03T03:52:22+00:00

I use VS2010 to generate a SQL Server Compact database with two simple tables.

  • 0

I use VS2010 to generate a SQL Server Compact database with two simple tables.

Both have a column TheID (int). On one I set unique to true on the other not.

And I set primary key on this column.

CREATE TABLE [TestTab] (
  [TheID] int NOT NULL
, [TheVal] nvarchar(100) NOT NULL
);
GO

ALTER TABLE [TestTab] ADD CONSTRAINT [PK_TestTab] PRIMARY KEY ([TheID]);
GO

For the other (with unique set on the column) I get:

CREATE TABLE [TestTab2] (
  [TheID] int NOT NULL
, [TheVal] nvarchar(100) NOT NULL
);
GO

ALTER TABLE [TestTab2] ADD CONSTRAINT [PK_TestTab2] PRIMARY KEY ([TheID]);
GO

CREATE UNIQUE INDEX [UQ__TestTab2__00000000000033E9] ON [TestTab2] ([TheID] ASC);
GO

Next I use the SQL Server Compact Toolbox to create a datacontext.

Selecting data works fine – but when I try to update the code it breaks on dc.SubmitChanges().

Simply my WP7 application ends.

A try / catch doesn’t help.

TestTab tT = (from A in dC.TestTabs select A).FirstOrDefault();

if(tT != null) {
    tT.TheText += "1";
    dC.SubmitChanges();
}

If I drop the unique index, the code works fine.

Any ideas why this happens?

Manfred

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:52:24+00:00Added an answer on June 3, 2026 at 3:52 am

    It is a LINQ to SQL on Windows Phone bug… Your index is a duplicate (the primary key definition also adds an index) – see my blog post here: http://erikej.blogspot.com/2012/04/windows-phone-local-database-tip.html. To get auto generated values, setting a primary keys is not enough, ypou must define the column as IDENTITY as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use VS2010, C#, ASP.NET; I read some data from SQL server and fill
Is there a way to use the SQL Model (dbml) builder in VS2010 using
I have been using LINQPad to prototype some queries against a SQL 2000 database,
We use Team Foundation Server (in VS 2010)... But how can I generate a
I have two databases : - a development database (for testing & dev) -
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I use VS2010, C# to develop ASP.NET web app, I create some sessions in
Can you use Ninject 2.0 with VS2010 RC1?
I'm using VS2010,C# to develop a Silverlight online game, I use keyboard for getting
Simply put: I have a database design in my head and I now want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.