Solved

Inserting/Updating Entity Framework 4 using SQL CE 3.5

Posted on 2010-09-22
5
1,050 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 63

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 63

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 63

Expert Comment

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

Expert Comment

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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

624 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