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.

Visual FoxPro Entity Framework Provider v2-Getting Started Using the EF Designer

Filed under: .Net Development — Tags: — Tom Brothers @ 3:41 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 the EF Designer with the new provider.  With the previous VFP EF Provider you could simply run the VfpEntityFrameworkProvider.msi installer and then have the provider available to you when you added a new “ADO.NET Entity Data Model” to your project.  But EF6 requires a little more setup to get started.  Most of this setup is handled by the VFPEntityFrameworkProvider2 NuGet Package.  So lets get started with the NuGet package and look at the details of what needs to be done.

 

Getting Started:

  • Install the VFPEntityFrameworkProvider2 NuGet package. 
    image
  • Make sure the VfpClient.dll and the VfpEntityFrameworkProvider.dll are set to copy local.  Normally I would just suggest this as a deployment option but now this is required to get the designer to work
    image

    Another requirement that the provider needs to be included in the config file (this is handled by the NuGet package). 

    image
  • Install the VfpEntityFrameworkProvider.msi which can be found in the packages directory. 
    image
  • Restart Visual Studio
  • If you try to add a new “ADO.NET Entity Data Model” you will find that the provider is not available.  The reason for this is that the EF6 Designer is looking for the EF Provider in the current project and is unable to find it until you build the project.  After building the project you will find that the provider is available when you try to add a new “ADO.NET Entity Data Model.” 
     
    image

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

Blog at WordPress.com.