Solved

Inserting/Updating Entity Framework 4 using SQL CE 3.5

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

734 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