Entity Framework 6

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Entity Framework 6

Daniel Rail
Hi,

  I'm trying to use the Firebird ADO.Net with Entity Framework 6.

  I'm able to create a code first model from an existing database.
  But, when trying to establish a connection, it is telling me that a
  provider is not registered. My scenario is that the connection is
  done in a DLL, not an EXE, and the main application's EXE that is
  calling this .Net assembly DLL is a Win32/Delphi application. I know
  that normally the provider information would be in the application's
  config file, but in this case the config file is not copied with the
  assembly DLL.

  I was reading on how to register the provider in code (
  https://msdn.microsoft.com/en-us/library/jj680699(v=vs.113).aspx ),
  but I'm unsure what to put for the SetExecutionStrategy line in the
  example.

  Any help would be appreciated.

--
Best regards,
 Daniel Rail
 Senior System Engineer
 ACCRA Solutions Inc. (www.accra.ca)
 ACCRA Med Software Inc. (www.filopto.com)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Paul Dryden-2

I have have had problems using Windows Entity Data Framework. In some cases, I can't open an edmx file in Visual Studio (that I had compiled from scanning a database perhaps a year earlier, always receiving "Provider Not Found." Very frustrating.

I am now considering switching to MySql, even though I would prefer to stay with Firebird.


On 2/9/2017 1:32 PM, Daniel Rail wrote:
Hi,

  I'm trying to use the Firebird ADO.Net with Entity Framework 6.

  I'm able to create a code first model from an existing database.
  But, when trying to establish a connection, it is telling me that a
  provider is not registered. My scenario is that the connection is
  done in a DLL, not an EXE, and the main application's EXE that is
  calling this .Net assembly DLL is a Win32/Delphi application. I know
  that normally the provider information would be in the application's
  config file, but in this case the config file is not copied with the
  assembly DLL.

  I was reading on how to register the provider in code (
  https://msdn.microsoft.com/en-us/library/jj680699(v=vs.113).aspx ),
  but I'm unsure what to put for the SetExecutionStrategy line in the
  example.

  Any help would be appreciated.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Jiří Činčura-2
In reply to this post by Daniel Rail
Well, you're not saying anything specific about the exception (at least
which provider - EF or ADO.NET?) nor how's the assembly loaded (because
you can as well use the config file, depending on how it's loaded).

Let's guess that it's a ADO.NET provider, then you're probably missing
the DbProviderFactory piece
(https://github.com/cincuranet/EF6_Firebird/blob/master/CodeFirst/App.config#L12).
With that, I would go the easiest way and pass directly FbConnection to
DbContext's ctor.

--
Mgr. Jiří Činčura
Independent IT Specialist

On Thu, Feb 9, 2017, at 21:32, Daniel Rail wrote:

> Hi,
>
>   I'm trying to use the Firebird ADO.Net with Entity Framework 6.
>
>   I'm able to create a code first model from an existing database.
>   But, when trying to establish a connection, it is telling me that a
>   provider is not registered. My scenario is that the connection is
>   done in a DLL, not an EXE, and the main application's EXE that is
>   calling this .Net assembly DLL is a Win32/Delphi application. I know
>   that normally the provider information would be in the application's
>   config file, but in this case the config file is not copied with the
>   assembly DLL.
>
>   I was reading on how to register the provider in code (
>   https://msdn.microsoft.com/en-us/library/jj680699(v=vs.113).aspx ),
>   but I'm unsure what to put for the SetExecutionStrategy line in the
>   example.
>
>   Any help would be appreciated.
>
> --
> Best regards,
>  Daniel Rail
>  Senior System Engineer
>  ACCRA Solutions Inc. (www.accra.ca)
>  ACCRA Med Software Inc. (www.filopto.com)
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Firebird-net-provider mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Daniel Rail
Hi,

At February 10, 2017, 3:28 AM, Jiří Činčura wrote:

> Well, you're not saying anything specific about the exception (at least
> which provider - EF or ADO.NET?) nor how's the assembly loaded (because
> you can as well use the config file, depending on how it's loaded).

> Let's guess that it's a ADO.NET provider, then you're probably missing
> the DbProviderFactory piece
> (https://github.com/cincuranet/EF6_Firebird/blob/master/CodeFirst/App.config#L12).
> With that, I would go the easiest way and pass directly FbConnection to
> DbContext's ctor.

Sorry, for not being clearer.

Here's  the  exact  error  message,  that  I receive when running from
Visual Studio:

[Error Message Quote]
An exception of type 'System.InvalidOperationException' occurred in
EntityFramework.dll but was not handled in user code

Additional information: No Entity Framework provider found for the
ADO.NET provider with invariant name
'FirebirdSql.Data.FirebirdClient'. Make sure the provider is
registered in the 'entityFramework' section of the application config
file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more
information.
[/Error Message Quote]

Here's the code that I use:

  using (var db = new FiloptoDataLibrary.FiloptoQuickBooksModel(new FbConnection(vFBConnectionString.ToString()), true))
  {
   ...
  }

The FiloptoQuickBooksModel is inherited from DbContext, and was
created by the Entity Framework Tools Code First from Database wizard.
The vFBConnectionString is a FbConnectionStringBuilder.

And, in the project's App.Config, all the entries are there. But, the
project compiles to a .dll and doesn't have a .config file with
it(when compiled). And, since the application that is calling this
.dll is not a .Net application(it's a native Win32 Delphi
application), I am trying to find out how to setup the entity
framework provider for usage in the .dll. And, since it is possible to
register the entity framework provider in code, in EF6, I'm wondering
what would be the required code, when trying to follow the example
from Microsoft, provided in the link of my previous message.

I am using Visual Studio 2015, EF 6.1.3 and targetting .Net 4.6.2.

I did thought of using the EntityConnectionStringBuilder, but it is
looking for the metadata files(.csdl, .ssdl, .msl), which don't exist
in my case. Unless, there is a way to tell it to ignore the metadata
files, when using the EntityConnectionString, because at least here I
would be able to specify the provider.

If more information is needed, just let me know.

--
Best regards,
 Daniel Rail
 Senior Software Developer
 ACCRA Solutions Inc. (www.accra.ca)
 ACCRA Med Software Inc. (www.filopto.com)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Daniel Rail
In reply to this post by Paul Dryden-2
Re: [Firebird-net-provider] Entity Framework 6 Hi,

At February 9, 2017, 6:52 PM, Paul Dryden wrote:


I have have had problems using Windows Entity Data Framework. In some cases, I can't open an edmx file in Visual Studio (that I had compiled from scanning a database perhaps a year earlier, always receiving "Provider Not Found." Very frustrating.

Actually, with Code First in EF6, I'm not dealing with an edmx file at all.

--
Best regards,
Daniel Rail
Senior Software Developer
ACCRA Solutions Inc. (
www.accra.ca)
ACCRA Med Software Inc. (
www.filopto.com)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Jiří Činčura-2
In reply to this post by Daniel Rail
> An exception of type 'System.InvalidOperationException' occurred in
> EntityFramework.dll but was not handled in user code
>
> Additional information: No Entity Framework provider found for the
> ADO.NET provider with invariant name
> 'FirebirdSql.Data.FirebirdClient'. Make sure the provider is
> registered in the 'entityFramework' section of the application config
> file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more
> information.

In your DbConfiguration class register the FbProviderServices. Here's a
field for that:
https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/master/Provider/src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbProviderServices.cs#L64
(you can also use the ProviderInvariantName).

> it(when compiled). And, since the application that is calling this
> .dll is not a .Net application(it's a native Win32 Delphi
> application), I am trying to find out how to setup the entity

Again. You're not saying how are you loading it. You can load DLL and
execute some code from it even with config file. Depends how you're
loading the CLR (and if, also).

--
Mgr. Jiří Činčura
Independent IT Specialist

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Jiří Činčura-2
Also, if you'd read my blog, you'd have been done already:
https://blog.cincura.net/233368-configuring-3rd-party-entity-framework-provider-firebird-from-code/
;)

--
Mgr. Jiří Činčura
Independent IT Specialist

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Daniel Rail
Hi,

At February 10, 2017, 8:13 AM, Jiří Činčura wrote:

> Also, if you'd read my blog, you'd have been done already:
> https://blog.cincura.net/233368-configuring-3rd-party-entity-framework-provider-firebird-from-code/
> ;)

Thanks, that's what I was looking for. I do remember coming across it,
but when I did, that wasn't the information that I was looking for at
the time. At first, I was just trying to figure out why I didn't have
the ADO.Net Entity Data Model template in Visual Studio, just to find
out, after searching for almost a day, that I needed to install either
the Web Developer Tools or SQL Server Data Tools, when installing
VS2015.

Anyway, thanks for the information and your hard work on the ADO.Net
provider.

--
Best regards,
 Daniel Rail
 Senior Software Developer
 ACCRA Solutions Inc. (www.accra.ca)
 ACCRA Med Software Inc. (www.filopto.com)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: Entity Framework 6

Daniel Rail
In reply to this post by Jiří Činčura-2
Hi,

At February 10, 2017, 8:12 AM, Jiří Činčura wrote:

>> it(when compiled). And, since the application that is calling this
>> .dll is not a .Net application(it's a native Win32 Delphi
>> application), I am trying to find out how to setup the entity

> Again. You're not saying how are you loading it. You can load DLL and
> execute some code from it even with config file. Depends how you're
> loading the CLR (and if, also).

Just to add to the context.

I'm using RemObjects Hydra as the plugin architecture, for our
application, and it's Hydra that loads the .Net assembly DLL. The DLL
is ComVisible. But other than looking in Hydra's code, I can't say how
the DLL is loaded.

Again thanks for the information.

--
Best regards,
 Daniel Rail
 Senior Software Developer
 ACCRA Solutions Inc. (www.accra.ca)
 ACCRA Med Software Inc. (www.filopto.com)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider