none
Using Entity Framework for SQL Compact Edition 3.5 does not respect mode=exclusive property of connection string. RRS feed

  • Question

  • I am using SQL Server Compact 3.5 edition with Entity Framework and I want to have exclusive lock on the database as documented here http://msdn.microsoft.com/en-us/library/ms171817.aspx.

    However when you pass this in a connection string to Entity Framework it does not respect this at all.

    An example of the connection string as following

    private static readonly string _ConnectionStringFormat =
               
    @"metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl; provider=System.Data.SqlServerCe.3.5; provider connection string='Data Source={0};Mode=Exclusive'";

    If anyone has come across this issue before and have found out how to resolve this, then please let me know.

    Thanks Aj

      Friday, April 16, 2010 8:44 AM

    All replies

    • Entity framework doesn't keep a connection to the underlying provider open throughout the life time of the app. Whenever it needs to prepare a query/run a query/load types etc. it opens the connection, does the required processing closes the connection after it is done. Since the properties like Mode can no longer be enforced after the connection is closed, you are seeing this behavior.

      http://msdn.microsoft.com/en-us/library/cc853327.aspx

      http://msdn.microsoft.com/en-us/library/orm-9780596520281-01-16.aspx (section "The Entity Framework and Performance").

      If you can elaborate on what you are trying to achieve, may be we can suggest a workaround.

      Thanks,

      -Deepesh


      Please hit "Yes", if my post answered your question(s). All postings are as-is and confer no rights.
      Thursday, June 24, 2010 6:47 AM