Set EntityFramework Provider from Code
Posted: Wed 18 Dec 2013 23:24
I'm developing a library that uses dotConnect for SQLite for code-first EntityFramework capability. In following the code based registration outlined here:http://blog.devart.com/entity-framework ... force.html I was able to get everything working within a test harness designed to test my library. Unfortunately, my current approach requires that I include the following sections in the main App.config file:
This is a problem as my library is being developed for a third party tool and I would rather not modify the App.config file of the parent application. Without this data in the App.config file I receive the following error:
"No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.SQLite'. Make sure the provider is registered in the 'entityFramework' section of the application config file."
Is there a way to configure the entity framework provider outside of the App.config file?
For a little more background, my DbConfiguration class is simply:
And the SQLiteConnectionFactory is a direct copy from the crmDemo that you provide.
Thanks!
Code: Select all
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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.SQLite" type="Devart.Data.SQLite.Entity.SQLiteEntityProviderServices, Devart.Data.SQLite.Entity, Version=5.1.55.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</providers>
</entityFramework>
"No Entity Framework provider found for the ADO.NET provider with invariant name 'Devart.Data.SQLite'. Make sure the provider is registered in the 'entityFramework' section of the application config file."
Is there a way to configure the entity framework provider outside of the App.config file?
For a little more background, my DbConfiguration class is simply:
Code: Select all
public class SQLiteConfiguration:DbConfiguration
{
public SQLiteConfiguration()
{
SetDefaultConnectionFactory(new SQLiteConnectionFactory());
SetProviderFactory("Devart.Data.SQLite",new SQLiteProviderFactory());
}
}
Thanks!