共用方式為


EF5 Sample Provider Published

We have published a new version of the sample provider that supports features introduced in the Entity Framework 5. It can be downloaded from the MSDN Code Samples Gallery.

This updated sample takes the sample provider code we released for Entity Framework 4 and demonstrates how to add support for spatial types and how to move to the new version of schema views to be able to reverse-engineer table valued functions (stored procedures with multiple resultsets did not require any changes to the provider). This version does not contain a sample provider for Migrations or Code First which currently use a separate provider model.

The tests (which are now using xUnit) not only test the sample provider but also show how to build queries leveraging features introduced in Entity Framework 5.

The code also contains a Data Designer Extensibility (DDEX) provider sample that now works with Visual Studio 11.

Note: To build and use the sample Visual Studio 11 and .NET Framework 4.5 is needed. xUnit test runner is required to be able to run the tests inside the Visual Studio. See the project page for more details.

Pawel Kadluczka,
Entity Framework Developer

Comments

  • Anonymous
    May 08, 2012
    Thats great, but.... ... is a sample provider for Framework 4 available somewhere? The blog post blogs.msdn.com/.../writing-an-ef-enabled-ado-net-provider.aspx is already referencing the the EF5 sample provider page. I would like to evaluate provider creation but in our project an update to EF5/.Net4.5 is not possible yet because lots of our customers still use XP.

  • Anonymous
    May 09, 2012
    I turned off the redirect from the old sample. I will add link to the EF4 sample from the new project site

  • Anonymous
    May 09, 2012
    Thank you very much, I just downloaded it :-)

  • Anonymous
    June 20, 2012
    The comment has been removed

  • Anonymous
    June 25, 2012
    @Pete Mack - I've added an item to our backlog to look at this scenario, at this stage it's not something we can do in EF5 though.

  • Anonymous
    June 25, 2012
    Hi! I have encountered a changed behavior in the EF CodeFirst. Since version 4.3 the DbProviderServices.CreateDatabaseScript method is used for database initialization by default, instead of the DbProviderServices.CreateDatabase method.  And it seems it just wouldn't fall back if the ProviderIncompatibleException was thrown, so my unit tests fail. My EF provider does not use any script (string) for data operations, so this gives me a great headache currently, because probably I should use ugly workarounds. What is the reason behind this change? Once someone implements the CreateDatabaseScript method, it is really easy to implement the CreateDatabase method too. The other direction is not that simple, like in my case. This is the implementation of my ProviderServices class, that used to work with EF 4.2. effort.codeplex.com/.../6d548c5eab06

  • Anonymous
    June 28, 2012
    @Tamas Flamich: In EF 4.3 support for Migrations was added. Migrations require __MigrationHistory table to work correctly. What the code does is first creating the database by calling then DbProviderServices.CreateDatabase() method and then the __MigrationHistory table is added by executing sql statement returned from ObjectContext.CreateDatabaseScript(). I will add a work item to handle the ProviderIncompatibleException exception. For now you could work around the problem by recognizing whether the CreateDatabaseScript is called for Migrations based on StoreItemCollection passed to the CreateDatabaseScript method and either return a hardcoded Sql statement or do nothing. Also, note that this behavior is also present in EF5.