Entity Framework 4.3.1 and SQL Server CE - entity-framework-4

I am following the official tutorial "EF 4.2 Model & Database First Walkthrough" using SQL Server CE 3.5 and alternative 4.0 versions. Unfortunately I always get an error:
EntityException {"The underlying provider failed on Open."} on
db.SaveChanges() command.
Why MS have such poor support for its own database?

Related

How to connect SQL Server Compact Edition database .sdf file to ADO Connection

I am trying to use a small .sdf database file created in SQL Server Compact Edition version 4.0 on Delphi application, but I cannot make a connection (ADO Connection) to this database. I have Windows 10 64bit OS, Delphi 10.2
I found tutorial for connection to .sdf file created on 3.5 version on this link:
http://slamingcode.blogspot.com/2014/06/connecting-delphi-with-sdf-sql-compact.html
It probably works on .sdf files created on 3.5 version, but when I try to connect "my file", I got error saying that database is created on different version and that I need to install specific DB provider.
So, I installed SQL Server Compact Edition v4.0, but it is only available for 64-bit system. After that, I manage to open and view database through LinqPad application (proof that DB provider was installed and that DB is created in version 4 of SSCE). But, in Delphi, there was no DB provider for SSCE v4.0 on ADO connection in the list.
Based on tutorial for setup 3.5 version in the link above, I found proper (I think) registry key for v4.0 (HKEY_CLASSES_ROOT\WOW6432Node\CLSID{2006C53A-C915-41EA-BAA9-9EAB3A1FBF97}) and added Key "OLE DB Provider" with value "Microsoft SQL Server Compact OLE DB Provider".
Now, I see DB provider in list of providers when I try to make Connection String. But, when I try to use that provider, I got Microsoft Data Link Error:
Provider is no longer available. Ensure that the provider is installed properly
Is it possible to connect Delphi to a .sdf file via ADO connection (or any other) and how?

entity data model wizard crashes with oracle connection

When trying to create model with entity frameowrk database first method, the entity data model wizard crashes. I am trying to connect to oracle database.
Oracle.ManagedDataAccess version :19.6
Oracle.ManagedDataAccess.EntityFramework version : 19.6
ODAC Version 18.3
Entity Framework Version:6.0
Image has been attached for refernce. Process after process mentioned in the image is crashing.
The rule still applies today. ODT Version must match the version of oracle.manageddataaccess and oracle.manageddataacess.entityframework obtained by nuget. It is very tempting to update thru nuget to a later version, but ODT will than crash.
I often have a parallel project to generate my code first model and than copy the files to my model project.
I'm using:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Microsoft ASP.NET MVC 5, NET.Framework 4.6.1
It was happening the same error in my project, I was tryng to use EnityFramework and Oracle Manage Data Access most recent versions. When downgrade the fallowing versions. It start to working without any errors
Versions that worked for me:
EntityFramework 6.1.3
Oracle.ManagedDataAcces 12.2.20230118
Oracle.ManagedDataAcces.EntityFramework 12.2.20230118
The EntityFramework 6.4.4 worked to... But every time I try to scaffold a Entity from the database, It autommatically downgrade to version 6.1.3

Using unmanaged Oracle.DataAccess driver with MVC5 and Entity Framework 6

For reasons beyond my control I have a working MVC5 app with an API using Entity Framework 6 and the Oracle Managed Data Access driver, but I need to switch this to use the unmanaged Oracle driver. I have Oracle Client v12.3 installed. I tried removing the managed Oracle .NET NuGet packages, referenced the unmanaged driver in the project, and changed all of the Oracle.ManagedDataAccess references to Oracle.DataAccess. The Oracle Client install seems okay because I have an older app that works and uses the unmanaged Oracle driver. Both apps are connecting to the same database.
The MVC app compiles and runs however when it attempts to connect to the database I get the following error when it constructs the DbConnection:
The Entity Framework provider type
'Oracle.DataAccess.EntityFramework.EFOracleProviderServices,
Oracle.DataAccess.EntityFramework, Version 4.112.3.0, Culture=neutral,
PublicKeyToken=89b483f429c47342' registered in the application config
file for the ADO.NET provider with invariant name 'Oracle.DataAccess'
could not be loaded. Make sure that the assembly-qualified name is
used and that the assembly is available to the running application.
Does the Oracle unmanaged driver support EF6 and if so what configuration am I missing to allow it to load the driver? Thanks!
EF6 does support Oracle.DataAccess. However, you can't do it via Nuget. Look at the link below for some guidance for someone that's actually resolve it.
Nuget package for Oracle Unmanaged Provider with Entity Framework

Differences in generated SQL - Local to Production Server

Our SQL DBA has pointed out that EF is generating some SQL that is causing implicit conversion and is leading to some performance problems. When I run the web application locally, I see a different query than the stage/production servers are generating. I am assuming that there are EF differences between my dev box and the server and need help determining where to look. I have verified the queries in SQL Profiler.
Local: Windows 7, 64-bit, IIS 7
Servers: Windows Server 2003, 32-bit, IIS 6
Linq statement (incoming is a List of type string):
var result = from i in context.ProductImages
where incoming.Contains(i.productID)
select i;
var sql = ((System.Data.Objects.ObjectQuery)result).ToTraceString();
return result.ToList();
Local generated query:
SELECT [Extent1].[column1],
[Extent1].[column2],
..rest of columns...
WHERE [Extent1].[productID] IN ('000176725','000176726','000176728')
Server generated query:
SELECT [Extent1].[column1],
[Extent1].[column2],
..rest of columns...
WHERE [Extent1].[productID] IN (N'000176725',N'000176726',N'000176728')
Any ideas on where to investigate to determine what is causing the generation difference? the "N'" is causing the performance challenge.
As far as I can tell, the System.Data.Entity dll is the same version (4.0.30319.1)
Looks like your server runs actual .NET Framework 4 while on your box you have .NET Framework 4.5. (note that the version of System.Data.Entity.dll will be the same). There was a bug in EF which was fixed in EF5/.NET Framework 4.5 and since .NET Framework 4.5 was an in-place update the fix is automatically picked up by apps that are using EF4 on boxes that have .NET Framework 4.5 installed.
You can change your app to work around the bug as described here.

Code First Entity Framework 5 and Oracle Data Client 11.2.0

I am trying to do Code-First development with EF 5.0 and Oracle Data Client 11.2.0. I have been reading online that 12c version of Oracle Client supports Code first but I am wondering if 11.2.0 supports it as well. I got my code to work Database-First approach but for the Code-First approach its asking me to set Sql Generator which I cannot find within Oracle Client 11.2.0. Am I doing something wrong or does oracle client 11.2.0 not support Code-First Approach?

Resources