Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi, I developed some applications already using Entity Framework 4.4 with the SQL Anywhere data provider for that EF version. Now that EF6 is supported by SQLA I'm evaluating how I can use it in new applications/ upgrade existing ones.

Since upgrading existing applications will take a while it would be nice if I could run EF4 and EF6 applications in parallel on the same machine. I think this should be possible without any problem, but I can't really find clear information how to deploy the corresponding SQLA data providers to the target system.

From another question ( I understand, that I should run SetupVSPackage with the /v 6 option. This works fine, but it replaces the EF4.x version of the data provider, which stops my older applications from working.

I'm using SQLA at the moment.

Any clarification on this matter would be highly appreciated.

Edit (in response to Jeff's answer):

I'm using visual studio 2012. Also I'm not using any EFTools (at least I think so, because I never consciously installed it). EFTools is mainly for things like model designer and generating models from existing databases, isn't it?

I get the following error message (I removed some of the app-specific paths and names):

System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
at iAnywhere.Data.SQLAnywhere.SAFactory.System.IServiceProvider.GetService(Type serviceType)
at System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory)
at System.Data.Common.DbProviderServices.GetProviderServices(DbConnection connection)
at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
at xxx.DataAccessor.GetUserName(Int32 userDsno) in ...

=== Pre-bind state information ===
LOG: DisplayName = EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Appbase = file:///C:/Projects/.../bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : iAnywhere.Data.SQLAnywhere.EF6, Version=, Culture=neutral, PublicKeyToken=f222fc4333e0d400.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\...\bin\Debug\SMR.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Attempting download of new URL file:///C:/Projects/.../bin/Debug/EntityFramework.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

This is the error I get using a Code-First app. Starting an app that uses EDMX model the error is slightly different (if that's of any interest):

System.Data.MetadataException: Schema specified is not valid. Errors: 
DataAccess.SMRModel.ssdl(2,88) : error 0004: Could not load file or assembly 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

asked 14 Jul '15, 10:20

Andre%20Hentschel's gravatar image

Andre Hentschel
accept rate: 0%

edited 15 Jul '15, 05:03

Hi Andre,

Unfortunately, the SQL Anywhere ADO.NET Provider is currently limited to only having one version registered as a DDEX Provider or DbProviderFactory underneath the invariant "iAnywhere.Data.SQLAnywhere". This means that you can't run parallel EF4/5 and EF6 installations with a single provider, and you also can't run multiple major versions of the SQL Anywhere ADO.NET provider for the same version of Entity Framework. Running SetupVSPackage.exe will always overwrite the previous configuration.

You can only register one SQL Anywhere ADO.NET provider for a major version, with either the EntityFramework 6 support enabled or not. If you need to change your configuration, you would need to re-run the SetupVSPackage.exe program for the version of the provider you're installing, with the appropriate options (i.e. /v 6).

We explored changing this behaviour in CR #767720 to allow multiple major version configurations, but unfortunately there isn't an easy solution to allow this type of configuration with the released versions of the providers.

which stops my older applications from working.

Can you perhaps post what the specific problem you're seeing is once you install the EF6 provider? We may be able to suggest a workaround, depending upon the error.

Which version of EFTools / Visual Studio are you using?

permanent link

answered 14 Jul '15, 13:25

Jeff%20Albion's gravatar image

Jeff Albion
accept rate: 25%

I posted the error message I get in my question. Is the EF6 data provider supposed to be backwards-compatible with EF4.x applications? Otherwise I can't see any real-world use for the EF6 provider, because I could potentially break other applications running on a system by switching provider versions.

(15 Jul '15, 04:41) Andre Hentschel

Actually, you might be able to get EF6 to co-exist with older versions on the same PC. I've managed to run an EF6 app on a PC that had an older version of the SQL Anywhere client installed (The highest version file was iAnywhere.Data.SQLAnywhere.v4.0.dll, which I believe is for EF4). The key is the SQL Anywhere <DbProviderFactories> registration in the machine.config, which is one the things that is configured when you run SetupVSPackage.

Assuming the machine.config has the SA EF4 provider registered, copy the EF6 provider config setting into the app.config. This overrides the SA EF provider in the machine.config with the provider declared in your app.config:

    <add name="SQL Anywhere 12 Data Provider" invariant="iAnywhere.Data.SQLAnywhere" description=".Net Framework Data Provider for SQL Anywhere 12" type="iAnywhere.Data.SQLAnywhere.SAFactory, iAnywhere.Data.SQLAnywhere.EF6, Version=, Culture=neutral, PublicKeyToken=f222fc4333e0d400"/>

Take care that the version number matches the version number of your iAnywhere.Data.SQLAnywhere DLL

I can now deploy my app (with iAnywhere.Data.SQLAnywhere.EF6.dll in the same folder) and it works.

permanent link

answered 06 Aug '15, 14:02

voonliew's gravatar image

accept rate: 25%

edited 08 Aug '15, 10:59

Thanks for the answer. If this works, it sounds like an acceptable way to do it. I'll try as soon as I have the time and will report back :).

(11 Aug '15, 10:07) Andre Hentschel
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 14 Jul '15, 10:20

question was seen: 4,810 times

last updated: 11 Aug '15, 10:07