Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1070
  • Last Modified:

Inserting/Updating Entity Framework 4 using SQL CE 3.5

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
brian_leighty
Asked:
brian_leighty
  • 4
1 Solution
 
Fernando SotoCommented:
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
 
brian_leightyAuthor Commented:
Once again you are awesome!
0
 
Fernando SotoCommented:
Well I am glad it worked out for you, glad to have been able to help.  ;=)
0
 
Fernando SotoCommented:
Please do not forget to close the question. Thanks.
0
 
Fernando SotoCommented:
Please do not forget to close the question. Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now