none
Entity Framework - Can not see inserted rows in database (programmatically inserted rows are cleared) RRS feed

  • Question

  • hello

    I insert row in database with entity framework by code, and I can retrieve them correctly.

    but, when I open database in visual studio database explorer and see data table, those rows

    that inserted programmatically, are cleared and I can not retrieve them programmatically after that.
    Saturday, July 26, 2014 8:25 AM

Answers

  • Hi A.Zareei;

    It sounds like you have a database file that is located within the project, local database, and is configured to always copy the database file to the bin directory each time the application is started. When it is configured in this way all reads and write will occur to the copy in the bin directory and NOT to the location that it was originally placed within the project. Therefore when you open the database at original location it seems like the new data was not persisted but in fact it was but not to the copy you are looking at. Look in your bin directory and open that copy to see what CRUD operations that were done. Please see this Microsoft documentation, "How to: Manage Local Data Files in Your Project", so that you can configure it to use the db file you want updated.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Saturday, July 26, 2014 12:39 PM