none
Entity model with SDF RRS feed

  • Question

  • Im trying to access data in a SDF file after I've created an entity model using the wizard and I keep getting the following error. Google is not helping much either : \

     

     

           System.ArgumentException was unhandled

      Message=The specified store provider cannot be found in the configuration, or is not valid.

      Source=System.Data.Entity

      StackTrace:

           at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)

           at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)

           at System.Data.EntityClient.EntityConnection..ctor(String connectionString)

           at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)

           at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)

           at TestModel.Database1Entities..ctor() in ..\visual studio 2010\Projects\NorthwindData\TestModel\Model1.Designer.cs:line 34

           at TestModel.Program.Main(String[] args) in ..\visual studio 2010\Projects\NorthwindData\TestModel\Program.cs:line 12

           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

           at System.Threading.ThreadHelper.ThreadStart()

      InnerException: System.ArgumentException

           Message=Unable to find the requested .Net Framework Data Provider.  It may not be installed.

           Source=System.Data

           StackTrace:

                at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)

                at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)

           InnerException: 

     

    I' m running Windows 7x64 & VS2010. Cant think that its a matter of something not being installed. The wizard seems to be able to access the SDF just fine.

     

     

     

    <connectionStrings>
        <add name="Database1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\Database1.sdf&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
    

     

     

    static void Main(string[] args)
        {
          Database1Entities context = new Database1Entities(); // exception in model designer
    
          Console.ReadLine();
    
        }
    

     


    Thanks for your time.

     

     

    Edit:

    Build target platform is set to x86

    • Edited by Louw Grobler Tuesday, January 10, 2012 1:39 PM more info
    Tuesday, January 10, 2012 1:35 PM

Answers

  • http://stackoverflow.com/questions/2540784/using-entity-framework-with-an-sql-compact-private-installation

     

    solved it for me.

    in short I just added the following to my app.config

     

    <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SqlServerCe.3.5"/>
          <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        </DbProviderFactories>
      </system.data>
    


    • Marked as answer by Louw Grobler Thursday, January 12, 2012 10:51 AM
    Thursday, January 12, 2012 10:50 AM

All replies

  • Hi Stalkerbee,

    Welcome to MSDN Forum.

    Based on the exception you posted, I think the root cause my be your data provider, try to download the suitable provider and test again.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, January 12, 2012 3:31 AM
    Moderator
  • http://stackoverflow.com/questions/2540784/using-entity-framework-with-an-sql-compact-private-installation

     

    solved it for me.

    in short I just added the following to my app.config

     

    <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SqlServerCe.3.5"/>
          <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        </DbProviderFactories>
      </system.data>
    


    • Marked as answer by Louw Grobler Thursday, January 12, 2012 10:51 AM
    Thursday, January 12, 2012 10:50 AM
  • Hi Stalkerbee,

    I'm glad to hear that you have solved the issue and thanks for sharing the solution. With your help, the forum will be better and better.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 13, 2012 2:04 AM
    Moderator