Random Dev Notes

December 15, 2013

Visual FoxPro Entity Framework Provider v2-Getting Started with Code First

Filed under: .Net Development — Tags: — Tom Brothers @ 4:31 pm

A new version of the Visual FoxPro Entity Framework Provider that targets EF6 is available.  The purpose of this blog post is to outline what you need to get started using Code First with the EF Power Tools Beta 4. 

Getting Started:

  • Install the VFP EF Provider Version 1.  The Version 1 build is required because the EF Power Tools doesn’t work with the new EF6 classes.
  • Install the VFPEntityFrameworkProvider2 NuGet package. 
    image
  • Run the Reverse Engineer Code First command.
    image
  • Change the data source to use the VFP Entity Framework Provider (EF4 & EF5) option.
    image
  • A connection string is added to your config file as part of the code generation process.  The connection string was generated to target the VFP EF Provider Version 1.  You will need to change providerName in the connection string to use VfpEntityFrameworkProvider2 to get Entity Framework to work with the VFP EF Provider Version 2.
    image
  • Add Attribute the DbConfigurationTypeAttribute to your DbContext class using the VfpDbConfiguration type.
    image

* Here is a video showing everything mentioned in this post.

10 Comments »

  1. HI Tom, great work!

    Question: does this also support the EF SqlMigrationProvider architecture, for live schema updates in production installations?

    Thanks,
    Jeff Bowman
    Fairbanks, Alaska

    Comment by Jeff Bowman — March 13, 2015 @ 7:22 pm

    • No, the migration code wasn’t fully implemented. The code to create the data structure was implemented but the code to update the data structure wasn’t. I don’t expect that it would be that much work to implement but I just never revisited that section of code when migrations were added.

      Comment by Tom Brothers — March 14, 2015 @ 11:58 am

      • Hmm… it doesn’t sound like it’d be too difficult to plug that in. I’d like to help you with that over the coming year, if you’re of a mind to. I was active in the VFP community some years back and I do miss it. There’s been nothing quite like it before or since 🙂

        Comment by Jeff Bowman — March 14, 2015 @ 3:48 pm

      • It would be nice to have someone else look into this code. The project is on github so feel free to implement this feature.

        Comment by Tom Brothers — March 15, 2015 @ 10:00 am

      • Very well, as time permits.

        Thanks,
        Jeff Bowman
        Fairbanks, Alaska

        Comment by Jeff Bowman — March 16, 2015 @ 5:36 pm

  2. Hi, I have made the installation of the VFP provider 2 and it worked properly but after restarting the machine and add new tables to edmx, the wizard generates an error indicating that DDEX provider is not installed for the VfpEntityFrameworkProvider2.

    I am using Windows 10, VS 2015 NET.Framework community with EF 4 and EF 6 have validated the machine.config and entries exist and are identical for both 32-bit and 64-bit

    I thank you can guide me to avoid setting VFP provider each time you start window.

    sorry for the English do not write or speak very well

    Comment by David Rodriguez — October 20, 2016 @ 10:15 am

    • Sorry, I don’t understand the issue. Could you send me a screenshot of the problem and possibly a stack trace? tombrothers@outlook.com

      Comment by Tom Brothers — October 21, 2016 @ 6:24 pm

      • Hi Tom

        DDEX is the Visual Studio Data Designer component, required for EDMX. I’m not familiar with the details. A good resource/contact for more info will be ErikEJ, who’s built the provider for SQLCE.

        HTH,
        Jeff

        Comment by intexx — October 21, 2016 @ 6:31 pm

  3. The VFP EF Provider includes a DDEX provider. What I don’t understand is how David got that error. It sounds like he was able to see the VFP Data Source option but then after selecting that he got the DDEX provider error. This situation is not something that I know how to reproduce.

    Comment by Tom Brothers — October 22, 2016 @ 6:39 am

    • My understanding is that there are two levels for DDEX—DataSource and EDMX. Apparently the latter is far more complex; Erik has declined to add it to his provider. Since EDMX is on its way out, this seems like a reasonable choice.

      Comment by intexx — October 22, 2016 @ 12:33 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: