Page 1 of 1

Entity Framework 6.1 not working with DotConnect for Oracle

Posted: Tue 12 Aug 2014 17:35
by patel1221
Hi,

I am using VS 2012 and EF 6.1. I have installed trial version of DotConnect for oracle to work with Code First approach with EF. But I am getting following error..
" Your project references the latest version of EF, however, an Entity Framework database provider compatible with this version could not be found for your data connection. If you have already installed a compatible provider, ensure you have rebuilt your project before performing this action. Otherwise, exit this wizard, install a compatible provider, and rebuild your project before performing this action"

Also, Devart provides only 2 options to work with EF. 1) Model first 2) Database first. I don't see Code First. I would like to use Code First with Oracle.

How to resolve all above issues?

I would like to use Code first approach.

Thanks,
Apatel

Re: Entity Framework 6.1 not working with DotConnect for Oracle

Posted: Wed 13 Aug 2014 07:22
by Shalex
patel1221 wrote:" Your project references the latest version of EF, however, an Entity Framework database provider compatible with this version could not be found for your data connection [...]
dotConnect for Oracle does support EF 6.1: http://blog.devart.com/entity-framework ... force.html.

With EDM Designer, you should add registration of EF6-provider in your app.config manually and rebuild the project before running the wizard (http://blog.devart.com/entity-framework ... gistration):

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.4.215.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Devart.Data.Oracle" />
      <add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=8.4.215.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>
Replace 8.4.215 here with your current version of dotConnect for Oracle. Please note that the revision number of provider in the entityFramework section is *.6 but in DbProviderFactories - *.0.

We recommend you to use Entity Developer (Devart Entity Model, *.edml) instead of EDM Designer (ADO.NET Entity Data Model, *.edmx) because it is adjusted for working with Oracle and has an advanced functionality: http://www.devart.com/entitydeveloper/ed-vs-edm.html. Additionally, Entity Developer adds registration of EF6-provider in app.config automatically.
patel1221 wrote:I would like to use Code first approach.
For this, please use Entity Developer with the DbContext (http://blog.devart.com/entity-developer ... plate.html) template. Just set "Fluent Mapping = True" property of the template. Then select designer surface and set the Metadata Artifact Processing property of EntityContextModel to Do Not Generate Mapping Files. Save the model and generate code. Is that what you mean?

Re: Entity Framework 6.1 not working with DotConnect for Oracle

Posted: Wed 13 Aug 2014 14:40
by patel1221
Shalex wrote: "For this, please use Entity Developer with the DbContext (http://blog.devart.com/entity-developer ... plate.html) template. Just set "Fluent Mapping = True" property of the template. Then select designer surface and set the Metadata Artifact Processing property of EntityContextModel to Do Not Generate Mapping Files. Save the model and generate code. Is that what you mean?"

I did follow above but it wasn't clear.

- In order to do above which one should I should (As Devart only provides 2 options to create model)?
1) Database first
2) Model first
- How and where I can find designer surface and Metadata Artifact Processing property?

Thanks,

Re: Entity Framework 6.1 not working with DotConnect for Oracle

Posted: Thu 14 Aug 2014 14:16
by Shalex
patel1221 wrote:- In order to do above which one should I should (As Devart only provides 2 options to create model)?
1) Database first
2) Model first
You can use any of these two options to create a model and generate fluent mapping basing on it. Take into account the following information:
1) Entity Developer includes the Update Model From Database and Update Database From Model wizards which can be applied to an existing model. So you can mix Database First and Model First approaches within the same model
2) once fluent mapping (using DbContext template) is generated, you can set the needed database initialization strategy in your code to make Entity Framework to generate the database basing on the code. This approach is used in case of Model First when there is no predefined database.
patel1221 wrote:- How and where I can find designer surface and Metadata Artifact Processing property
Double click YourModelName.edml, select surface of the opened diagram, press F4 and look for Metadata Artifact Processing in the Properties window.