Random Dev Notes

October 23, 2011

VFP Entity Framework Provider (v0.5)

Filed under: Development — Tags: — Tom Brothers @ 7:46 pm


I’m back it again… working on another LINQ provider for Visual FoxPro data.

Introduced back in 2009, LINQ to VFP was my first attempt at writing a LINQ provider that accessed Visual FoxPro data.  That provider worked well but had a few drawbacks that I was willing to live with at the time due to the lack of options.     The most notable drawbacks include not having a designer/code generator and requiring special code to get it to work with other Microsoft offerings such as WCF Data Services.  Additionally, there were some usability limitations due the framework that LINQ to VFP was build upon (IQToolkit).  I was able to code my way around most of these issues but I still felt that the whole process wasn’t all that developer friendly.  What I really wanted was a more integrated development process that could easily hook into new Microsoft offerings (such as LightSwitch).  So I started to look into what it would take to create an Entity Framework 4 Provider.  Fortunately I found that there was a starter project available.  I modified this project to work with Visual FoxPro data and now have what I’d like to consider a proof-of-concept build ready for testing.

* Note:  This build only works for “Database first” scenarios.

See In Action

A sample application (VfpEFQuerySamples) is available to see the provider in action.  This application is a copy of the ADO.NET Entity Framework Query Samples configured to work with Visual FoxPro data.

* Notes:
  • Installing the Visual FoxPro Entity Framework Provider is not required to run this application
  • The VfpOleDb driver must be install otherwise you will see the following when you try to run the samples

Install Steps

  • Download and run the VfpEntityFrameworkProvider.msi from the codeplex site.

* UPDATE:  Starting with version 0.6.1, the installer will update the machine.config so no need to manually make this change.

  • Add an entry for the provider in C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config. 
    <add name="Vfp Entity Framework Provider" 
         description="Vfp Entity Framework Provider" 
         type="VfpEntityFrameworkProvider.VfpProviderFactory, VfpEntityFrameworkProvider, Version=, Culture=neutral, PublicKeyToken=feace53afe38fe48"/>

How to add to a Project

  • Add a new ADO.NET Entity Data Model
  • Select “Generate from database”
  • Click on the “New Connection…” button and select the VFP Provider
  • Enter the connection information
  • Continue with the following wizard screens

    imageimage image image

  • After completing all the wizard screens you will see the EF designer and depending on your data you may see messages similar to the following.  This is expected behavior from the Entity Framework and is not specific to the Visual FoxPro Entity Framework Provider.


There are two options for deploying an application using this provider. Both options required the provider information to be added to the machine.config or the project’s app.config/web.config.

  1. Install the VfpEntityFrameworkProvider.msi. This installer includes the VfpOleDb driver.
  2. Include the VfpEntityFrameworkProvider.dll in the project. You will also need to ensure that the VfpOleDb driver is installed.


Known Issues

  • The generated sql statements could be improved to use more concise syntax
  • I haven’t figured out how to hook into “Generate Database” screen so it currently shows commands for Sql Server instead of Vfp.

  • The provider only woks in the non-Express versions of Visual Studio.  This is not because I’m intentionally restricting the Express Products but instead because I haven’t figured out the registry settings yet.

Blog at WordPress.com.