SQLite wrapper 1.0.77 and Entity Framework under .NET 4 - entity-framework

We are developing a windows application on .NET 4, it uses SQLite database with .NET wrapper System.Data.SQLite and Entity Framework. On deployment machine it requires .NET 4 Client Profile.
The latest official release (1.0.66) of SQLite wraper is 2 years old. This version works with .NET 2.0 — 3.5, it's mean that we should force users to install 2 versions of .NET. Also it does not supports foreign keys.
There is also unofficial release 1.0.77 which supports foreign keys, however, support of ORM (.NET Entity Framework) is broken in this version (It raises System.Data.ProviderIncompatibleException).
I can see three ways to fix this issue:
Abandon the use of this wrapper and look for other options. What would you suggest?
Abandon the use of Entity Framework. This option is undesirable because it is old-school way and also require us to rewrite a lot and write more code and increate the likelihood of bugs.
Try to fix an issue with 1.0.77, but I have no idea how long it can take. What would you do in this situation? What other wrappers we should look at?

Finally, I understand how to let 1.0.77 System.Data.SQLite assembly to work with Entity Framework and without placing assembly to the GAC.
My first tries to connect SQLite 1.0.77 resulted in:
System.Data.ProviderIncompatibleException: A null was returned after calling the 'GetService' method on a store provider instance of type 'System.Data.SQLite.SQLiteFactory'. The store provider might not be functioning correctly.
Code analysis showed to me that main assembly System.Data.SQLite.dll can't find System.Data.SQLite.Linq.dll. The second assembly has been referenced in project and existed in output bin folder. But the error didn't disappeared.
Reflector showed that System.Data.SQLite.Linq.dll has no public classes. So it will never load automatically to app domain because there is no code referencing it. So it must be only in GAC for correct working.
But nothing can deny us to load it manually to app domain! For example, at application start:
Assembly.Load("System.Data.SQLite.Linq");
And that's it!
Also, don't forget about adding this lines to your application config:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.77.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
</DbProviderFactories>
</system.data>
Hope my expierence will be usefull.

Related

PostgreSQL with EntityFramework in MonoDevelop on Ubuntu

I tried to configure a project in MonoDevelop on Ubuntu, to use EntityFramework with Npgsql provider, by following official steps.
However, something seem to be wrong with that suggested configuration file (or I'm missing something), as I can't get rid of this error:
The Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql.EntityFrameworkLegacy, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Does anyone have a simple working example of the application connecting to PostgreSQL using Entity Framework in MonoDevelop?
Please try with Npgsql 3.0.3 (the error says 2.1.0), the correct package for this would be EntityFramework6.Npgsql, not Npgsql.EntityFrameworkLegacy.

EntityFramework: unable to determine the provider name for provider factory of type 'system.data.sqlclient.sqlclientfactory'

I have an Website that use Entity Framework and SQLServer.
WHen I trying to run my application on Azure I get the following error:
Unable to determine the provider name for provider factory of type 'system.data.sqlclient.sqlclientfactory'. make sure that the ado.net provider is installed or registered in the application config.
On premises everything works fine.
I have finally discovered that the error was caused by this configuration section (that now I don't use anymore):
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, mysql.data" />
</DbProviderFactories>
</system.data>
I have removed it and now it worked correctly.
For future readers, this same error can also be seen when using Visual Studio 2017 v.15.7. I spent days browsing the web for solutions, and stubled upon this GitHub post mentioning a bug in EF Tooling. An update to v.15.8 as mentioned in the post solved the problem for me.

Does DotNetOpenAuth 4.3 work with Entity Framework 6?

I created an empty project in VS2013 and added these packages:
DotNetOpenAuth.AspNet
Microsoft.AspNet.Providers.Core
Microsoft.AspNet.Providers.LocalDb
Microsoft.AspNet.Membership.OpenAuth
In the process, Entity Framework 5 was added to the project. I manually installed EF6 and now I get this error when I try to authenticate a user with an external provider:
"Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'."
I checked the DNOA documentation but it does not say a word about dependencies/requisites.
Does anybody know if DotNetOpenAuth can work with EF6?
DotNetOpenAuth does not have EntityFramework as a dependency. The samples however do use EF. You must have some of your own code that uses entity framework.
That said, it sounds to me like you need to add a binding redirect or jiggle your entityframework configuration a bit in your web.config file.

WCF Ria Services Wizard not working with CodeFirst

When using EF Code First, It appears WCF RIA Services Wizard (that runs when adding a new DomainService) in VS 2012 does not recognize the DbContexts defined in the project (it only recognizes the ObjectContext).
This means that when Adding a New Item in VS2012 and choosing Add DomainServiceClass, the wizard is not able to detect available context classes * combo list is empty *
Please see the attached image
Any idea what could be happening here?
Thanks,
-Sumit
This is a known issue with Visual Studio 2012, WCF RIA Services and Entity Framework, cause the Wizard to create new Domain Services doesn´t know the DbContext types.
The simple solution is to continue using Visual Studio 2010 to create Entity Models. Although using RIAServices.EntityFramework NuGet package won´t work, cause it doesn´t support current Versions of Entity Framework.
Another solution is to change the type of your Context from DbContext to ObjectContext.
Theres also a KB article for that specific scenario.
Update:
An update to WCF Ria Services was released to support EF 5 and the usage of DbContext. More information can be found here.
I believe that the wizard don't find your class due to the fact that WCF ria is older than EF 5. Try to redirect the assembly binding to
<runtime>
<legacyUnhandledExceptionPolicy enabled="1" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
...
let us know if it works
This is now possible with the 4.2 release of WCF RIA Services.
If you create a WCF RIA project and get prompted to select a Windows Phone version, this is a reported issue you need remove Windows Phone 8.0 & 7.1 SDK.
If then you get an error to do with project templates perform a repair on WCF RIA 1.0 SP2 which you should have already installed.

Deploying Devart EF Odata app to a Server - cannot find Framework Data Provider

I followed the simple tutorial # http://www.devart.com/dotconnect/oracle/articles/Tutorial_EF.html
(Which works perfectly, btw) combined with http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx for the OData part and now I need to deploy it to a server.
The problem I am having is that in step 4 of the devart tutorial, I chose a "Data Connection" to my database. Everything works fine on my dev box, but when I published the EF project, there was no reference to the DevArt dlls in the project. So, none were moved to the server.
And, of course this is producing a 'Unable to find the requested .Net Framework Data Provider. It may not be installed.'.
I tried just copying the dlls into the bin directory and I installed the devart product on the server. Neither worked.
I am used to ASP.Net applications that reference the needed Data dlls. What do I need to do to get my EF Odata service running?
The following page will explain how to deploy your EF devart project:
DevArt - Deployment