Random Dev Notes

August 31, 2012

VFP Entity Framework Provider (v0.7.0)

Filed under: .Net Development — Tags: — Tom Brothers @ 9:48 am

It has been awhile since I blogged about an update to the VFP Entity Framework Provider.  Here is a list of changes since my last post (which was for v0.6.1).


  • (v0.6.2) – Modified the schema retrieval code to treat a free table candidate key as a primary key.
  • (v0.6.2) – Fixed bug related to using character field as a primary key.
  • (v0.6.3) – Added support for binary char, binary varchar, binary memo, date, and Guid.
  • (v0.6.3) – Fixed issue with Inserting/Updating DateTime values.
  • (v0.6.4) – Changed how columns are aliased in a query.
  • (v0.6.5) – Changed the way Decimal, Double, and Single values are written as part of DML commands to deal with localization issues.
  • (v0.6.5) – Made various changes to shorten the SQL command text length to help prevent "VFP Error 1812 – Statement too long" errors.
  • (v0.6.6) – Modified the SELECT statement to include a CAST(<fieldname> AS N(20, <scale>)) for Numeric values that include a decimal. To address this type of issue.
  • (v0.6.7) – Changed how Single, Double, Decimal, and DateTime constants are written out for the sql statements.
  • (v0.6.8) – Changed data manipulation statements to parameterize some types to fix localization issues and to prevent invalid statements due to carriage returns in strings.
  • (v0.6.9) – Modified installer to include setup for VS2012.
  • (v0.7.0) – Improved performance of generating the edmx
  • (v0.7.0) – Refactored ADO.Net related code to use VfpClient.

There have been several updates along the way which really didn’t warrant a blog post which I why I haven’t written one.  This release isn’t much different as far as blog worthy content.  However, there were a few minor design time changes that should make things a little nicer (at least that is what I think) so I’ll go ahead and point them out.

Before digging into the changes I’d like to mention the refactoring effort that was made for this release.  The VFP Entity Framework Provider was originally developed using the System.Data.OleDb.* classes to connect to the VFP data – which is probably what you’d expect.  These classes required wrapper classes to handle some Entity Framework expectations.  What expectations?  Well lets just state the obvious which is the Entity Framework was original targeted for SQL Server.  So what does that mean as far as expectations?  In short I would say that if the System.Data.SqlClient.* classes “do it”… then the classes that the VFP Entity Framework Provider uses needs to “do it” too.  One good example would be that the SqlCommand class uses named parameters.  So the SqlCommand equivalent that VFP Entity Framework Provider uses must support named parameters.  In this case I needed to create a wrapper class around the OleDbCommand that could handle the concept of named parameters.  Doing this in the VFP Entity Framework project was actually the second time that I needed to write this wrapper class.  The first time was in the LINQ to VFP project.  Needless to say that having similar code in two different projects just didn’t seem right.  So I decided to pull the OleDb wrapper classes from both projects and place them in a new project.  VfpClient is the new project that was created with the wrapper classes but the development didn’t end there.  I also pulled in the Sedna DDEXProvider project (Microsoft.Data.FoxClient) which started me down the path of customizing the design time experience.  So coming back from what must seem like a tangent…  the VFP Entity Framework Provider was refactored to use VfpClient which includes a couple design time changes.

Even though this isn’t my first blog post for the provider I thought that it would be nice to take a step back and show how to install the provider.  I also thought it would be nice to show an example of it in use so that I can point to this post as a “Getting Started with” post since a couple screens have changed.



To install the provider you just need to download and run the VfpEntityFrameworkProvider.msi from http://vfpefprovider.codeplex.com/.


Here is a quick video showing the provider in use.


For those familiar with the provider… here is an overview of the changes:

(Old screen is on the left the new is on the right)

  • Added the "Visual FoxPro Data Client" data source so that you didn’t have to dig through the "<other>" selection.
    image image
  • Simplified the Connection Properties so that you just need to specify a path.
    image image
  • Moved the Advanced Properties to a separate dialog.  (only included a few of the properties… will add more as needed)
    image image
  • The Connection Name, in Server Explorer – Data Connections, is set to the Data Source instead of being hardcoded to “Visual FoxPro Data.”
    image image
  • The Schema properties for Table, Fields, Views, and Stored Procedures are VPF specific values (using DBGETPROP).
    image image
    image image


  1. Hi Tom
    New to c# and VFP so please excuse my ignorance.. I have downloaded the VFP EF but when I try to access it via the connection string it does not appear in the list?

    The foxpro files I am trying to access are via a ‘directory’ where the .dbf and .cdx files are located … currently I am using a linked server via SQL to access these but would love to get EF working for VFP..
    Any help appreciated..


    Comment by Graham — November 11, 2012 @ 12:56 am

    • Could you send me some screen captures (tombrothers@outlook.com) so that I can get a better idea of what you are doing and why it isn’t working?

      Comment by Tom Brothers — November 11, 2012 @ 9:38 am

  2. I am getting an error trying to install the VfpEntityFrameworkProvider.msi file. I am installing it on a Windows 7 64-bit system. It starts the installation process but finally ends with the following screen text: “Visual FoxPro Entity Framework Provider Setup Wizard ended prematurely”. The Application event log has this text: “Windows Installer installed the product. Product Name: Visual FoxPro Entity Framework Provider. Product Version: Product Language: 1033. Manufacturer: Tom Brothers. Installation success or error status: 1603.”

    Comment by Larry Huisingh — May 20, 2013 @ 12:07 pm

    • This is usually due to security issues. Try the instructions in this discussion thread to see if that fixes the problem for you.

      Comment by Tom Brothers — May 20, 2013 @ 12:35 pm

      • Thank you. That helped. Do I also need to install the VFP Client?

        Comment by Larry Huisingh — May 20, 2013 @ 1:49 pm

      • No, VfpClient is installed as part of the VFP EF Provider install.

        Comment by Tom Brothers — May 20, 2013 @ 2:08 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: