cannot insert after UpdateSchema()

Thread is closed for posting
2 posts, 0 answers
  1. Chom
    Chom avatar
    56 posts
    Member since:
    Dec 2009

    Posted 29 Aug 2013 Link to this post

    I have built a fluent context model using code only and I can create table no problem after calling the context.UpdateSchema().

    However when I try to insert some data into a table after I call UpdateSchema() the data does not get inserted in tot he table.

    public static void InsertManufacturerInfo(string ProjectFilePath, string ProjectName)


    using (ProjectSqlCeFluentContext db = new ProjectSqlCeFluentContext(ProjectFilePath, ProjectName))


    //Create and/or update schema before adding any data....


    Platform p = new Platform


    Manufacturer = "some name here",

    PlatformType = "my platform"






    Does anybody know what the problem is?

    Help much appreciated.


  2. Doroteya
    Doroteya avatar
    498 posts

    Posted 30 Aug 2013 Link to this post

    Hi Chom,

    Generally, the described behaviour is caused by a peculiarity in the process of persisting data to the database file in SQL Server Compact Edition. The posted method indeed creates/updates the schema and SaveChanges() commits the new record in memory but if the process is terminated before the disposal of the context (and the connection used in the transaction), the physical file is not updated.

    A solution is to set the Flush Interval property of the connection string to 1. That way data will be written to the database file after the call to SaveChanges().

    Please kindly find additional details about your scenario in the corresponding support thread.

    If you experience other issues or have questions, do not hesitate to get back to us.

    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top