Random Dev Notes

May 6, 2012

Using VFP Entity Framework Provider with Free Tables using Code First

Filed under: .Net Development — Tags: — Tom Brothers @ 3:37 pm


In my previous post, titled “Using VFP Entity Framework Provider with Free Tables”, I outlined a way of connecting the VFP Entity Framework Provider with Free Tables.  The post was really geared towards an “out of the box” experience – said another way it was more specifically an Entity Framework 4.0 way.  Although I feel the post is relevant, it really didn’t sit well with me because it is not the way I would have done things.  This post will outline another way of connecting Free Table DBFs with the VFP Entity Framework Provider using Code First (or Entity Framework 4.1+).

(This post assumes you’ve already installed the VFP Entity Framework Provider)

Getting Started

Create a console application.


Create the Entities.

  1. Install the Entity Framework Power Tools
  2. Use the Power Tools to generate the code first entities.
  3. You’ll be prompted for the connection information.
  4. A new Models folder has been added to the project.

Alter the Model

I’ll alter the Blog_Lookups table just list in the last blog post.

Here is the code that was generated:


Using Visual Studio’s refactoring I renamed the class name and some of the properties.


One other thing that needs to be done which I couldn’t do in the last example is set the primary key to the correct column.



* One benefit of the using the Code First approach makes it easier to set the primary key when your table doesn’t include a candidate key.

« Newer Posts

Blog at WordPress.com.