Solved

Inserting/Updating Entity Framework 4 using SQL CE 3.5

Posted on 2010-09-22
5
1,038 Views
Last Modified: 2012-08-13
I've setup a project using a Entity model built from scratch and added a SQLCE database as the backend.  Everything seems fine except for when I call  "entity.SaveChanges();"    I have set this in a loop hoping to create 10 records and nothing happens.   How else would I insert/update a SQLCE database using Entity Framework 4?    Thnaks

using (ModelContainer entity = new ModelContainer())
{
 Repository repository = new Repository
{
ID = Guid.NewGuid(), created = DateTime.Now, source = "This is a source document" + i, deleted = false, filename = "Test" + i + ".pdf"
};

entity.Repositories.AddObject(repository);
entity.SaveChanges();
}
0
Comment
Question by:brian_leighty
  • 4
5 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 33739347
Hi Brian;

Well I think you may have an issue with which database the system is using, the one you told where it is and the one the system copies to the debug directory and overwrites? see this artical :

A few SQL Server CE and Entity Framework Gotchas
http://thedatafarm.com/blog/data-access/a-few-sql-server-ce-and-entity-framework-gotchas/

He point out two other links which you should look at in the paragraph :

Check Josh's blog post ".NET Frustrations" and Tim's post, Where is your SQL Server CE Database?, for more details.

Fernando
0
 

Author Comment

by:brian_leighty
ID: 33740435
Once again you are awesome!
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 33740699
Well I am glad it worked out for you, glad to have been able to help.  ;=)
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 33740716
Please do not forget to close the question. Thanks.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 33740721
Please do not forget to close the question. Thanks.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now