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).

Changes:

  • (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.

 

Install

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

Example

Here is a quick video showing the provider in use.

Changes

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

Blog at WordPress.com.