Solved

Inserting/Updating Entity Framework 4 using SQL CE 3.5

Posted on 2010-09-22
5
1,034 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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…

747 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

14 Experts available now in Live!

Get 1:1 Help Now