Entity Framework 5 Sample Provider

This sample demonstrates how to create a custom provider that supports the new features introduced in EF 5

C# (676.5 KB)
4.8 Star
12,513 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • Disposable Command
    1 Posts | Last post June 16, 2015
    • Apologies if my question seems dispensable.
      I've been looking into the Sample Framework Provider to understand how EF utilizes it to produce SQL and thus hopefully be able to customize it.  Here comes my (rather general) question:
      The SampleCommand wraps an internal Command in the Property _WrappedCommand - just like the SampleConnection.  The SampleConnection implements a Dispose function to dispose the wrapped connection.  Why doesn't the SampleCommand implement a Dispose function as well (especiall since it is cloneable)?
      Thanks in advance,
  • Error compiling the sample
    2 Posts | Last post March 01, 2014
    • When attempting to compile the sample application, FunctionStubGenerator crashes, and  the following error occurs:
      Error	2	The command ""%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /if "SampleEntityFrameworkProvider.dll"" exited with code 1.	SampleEntityFrameworkProvider
    • Can you check if the file "%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\Bin\NETFX 4.0 Tools\gacutil.exe" exists on the disk?  Because the Error 2 indicates that it does not exist ("The system cannot find the file specified.") which probably means that you don't have Visual Studio SDK installed. You can download Visual Studio 2012 SDK from here: http://www.microsoft.com/en-us/download/details.aspx?id=30668
  • EFProviderWrapperToolKit with EF6
    2 Posts | Last post May 07, 2013
    • Hi,
      We have used EFProviderWrapperToolkit and developed own customized provider. The main purpose of own provider is to support connection pooling in multi-tenancy scenario. 
      It was working fine with EF4.3 Code First model, but stopped working with EF6. 
      I have posted my issue here:
      It would be great if you can provide some guidance how to use them with EF6 and develop own provider? Or how can we achieve Connection Pooling?
    • The provider model in EF6 has changed. First of all you need to use an EF6 provider. If you are using Sql Server the EF6 Sql Server provider is included in the EF6 package. Since the wrapping provider is just another provider you should read and follow [the document about rebuilding a provider for EF6](http://entityframework.codeplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6) and the wrapping provider should continue to work. Note that the document contains a section about wrapping providers in EF6. In addition in EF6 we introduced [dependency injection and code-based configuration](https://entityframework.codeplex.com/wikipage?title=Code-based%20Configuration) which makes some aspects of wrapping easier.
  • Custom provider for ODBC
    3 Posts | Last post February 28, 2013
    • SAP has not released any entity framework provider so far for HANA. 
      It has shipped ODBC driver. I have downloaded the sample for writing custom provider, and started developing a provider for SAP HANA. 
      I wanted to get help on this. If someone can let me know if there is any other sample which is more close to ODBC connectivity and ANSI sql generation which I should take as base and start customizing for HANA or I have no other choice but to use the same sample. 
      Also, instead of SqlClient library I am using System.Data.Odbc and creating odbcconnection and odbccommand etc. I hope that is the way to go.
      Thank you for all your help.
    • Entity Framework provider is based on ADO.NET provider model so it's not possible use ODBC directly. What you can try is to wrap your ODBC classes with ADO.NET classes (e.g. DbConnection derived class would wrap the OdbcConnection, DbCommand derived class would wrap OdbcCommand class and so on). I am not aware of any ODBC based driver for Entity Framework. 
    • Hi Rohit,
      I would recommend not getting into this project without reading the blog series by legendary Matt Warren:
      The project is also on codeplex: 
      I also am in need for HANA EF provider but after getting to know this a little bit, I think this is something SAP should take on rather than individual programmers.
      Also, please consider deriving from the ADO.NET components family to provide HanaCommand, HanaConnection, HanaQuery etc.
      Please let me know of further developments.
  • Sample doesn't compile
    2 Posts | Last post November 16, 2012
    • Error	1	The remote server returned an error: (407) Proxy Authentication Required.	ProviderTests
    • The tests are using XUnit. XUnit assembly is not part of the project but -if needed - is downloaded from nuget. This is done using another nuget package (nuget.commandline) that is actually hosted on nuget - here is the link to this package http://nuget.org/v1/FeedService.svc/Packages()?$filter=tolower(Id)%20eq%20'nuget.commandline'&$top=1&$orderby=Version%20desc. Seems that for some reasons nuget cannot be reached when building the project which is a reason for the failure. Can you try connecting to nuget from your browser (use the above link) and see if it works? Apparently it 
  • Failed to process generated SQL string from Entity Framework by my custom ado.net provider
    2 Posts | Last post August 02, 2012
    • Hi, 
      I am working on my custom provider to support Entity Framework. I have followed the sampleentityframeworkprovider project and made enough progress. My problem is now when I select a table from ADO Entity Data Wizard and hit “Finish”, Entity Framework generates SQL strings in four passes specific to my store. The first pass is for the Table and it goes through fine, the second pass is for View and it processes fine. But on the third pass, which is for Constraints, my provider failed to process the generated SQL string.
      I have implemented DBProviderServices and DBProviderManifest. Most of the SQL generation codes are very similar to the sampleentityframeworkprovider except I had to change some sql generation code to my store specific dialect. 
      MS ADO provider, the first 3 sql generation starts with:
      [Join5].[Ordinal] AS [C1], 
      [UnionAll4].[CatalogName] AS [C2], 
      [UnionAll4].[SchemaName] AS [C3], 
      [UnionAll4].[Name] AS [C4], 
      [Join5].[Name1] AS [C5], 
      [UnionAll5].[CatalogName] AS [C6], 
      [UnionAll5].[SchemaName] AS [C7], 
      [UnionAll5].[Name] AS [C8], 
      [Join5].[Name2] AS [C9], 
      [Extent2].[Name] AS [Name], 
      [Extent1].[Id] AS [Id], 
      CASE WHEN ([Extent1].[DeleteRule] = 'CASCADE') THEN cast(1 as bit) WHEN ([Extent1].[DeleteRule] <> 'CASCADE') THEN cast(0 as bit) END AS [C10]
      My ADO provider, all 3 sql generation starts with:
      "Project3"."C11" AS "C1", 
      "Project3"."CatalogName" AS "CatalogName", 
      "Project3"."SchemaName" AS "SchemaName", 
      "Project3"."Name" AS "Name", 
      "Project3"."C1" AS "C2", 
      "Project3"."C3" AS "C3", 
      "Project3"."C4" AS "C4", 
      "Project3"."C5" AS "C5", 
      "Project3"."C6" AS "C6", 
      "Project3"."C7" AS "C7", 
      "Project3"."C8" AS "C8", 
      "Project3"."C9" AS "C9", 
      "Project3"."C10" AS "C10", 
      "Project3"."C12" AS "C11"
      My question is, even I am using almost same sql generation code, why is the difference.
    • It's hard to tell why you see a different output without knowing/seeing the differences in SQL generation code. You could debug EF Sample Provider and your provider side by side to figure out where the differences start - this will be most likely the place to take a deeper look at.