View Ticket
Not logged in
Ticket UUID: 7eba26f7e4920ae374428e3d00667a646613f6b5
Title: SetProviderFactory method can't use in x86 .NET 4.0
Status: Closed Type: Build_Problem
Severity: Important Priority: Medium
Subsystem: None Resolution: Open
Last Modified: 2015-08-30 17:36:14
Version Found In:
User Comments:
anonymous added on 2015-08-30 16:56:32:
Normally we add some messages in config files. for example:

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameter value="v12.0"/>
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>

I search some message tell me I can use this way add it in code:

public class SQLiteConfiguration : DbConfiguration
        public SQLiteConfiguration()
            SetProviderFactory("System.Data.SQLite", System.Data.SQLite.SQLiteFactory.Instance);
            SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
            SetProviderServices("System.Data.SQLite", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));


Then add this class to DbContext head as a Attribute: [DbConfigurationType(typeof(SQLiteConfiguration))]

I'm using vs2013, So I install x86 .net4.5.1 vs2013.msi. After generate my model. I reference .net4 x86 version System.Data.SQLite.dll (I'm very tired of this, but no other way, my project need use .net4 version System.Data.SQLite)

Then when I build my project it tell me, my model project has some references with .net4.5.1, then I throw exception, build failed.

After I remove SetProviderFactory method. All fine.

So How do I fixed that?

Or can you tell me how do I manually add that config field use code. Thank you very much

anonymous added on 2015-08-30 17:36:14:
problem solved, I just need let System.Data.SQLite set to copy to local. Looks like 2 .net version has Conflict. Sorry for that.