I must link my IBM Db2 database with my ASP Net 5 application.

I came across these nuget packages:

And I adhered to this instruction:

But that is ineffective.

my endeavor. json

"dependencies": {
"EntityFramework.IBMDataServer": "7.0.0-beta1",
. . .


Starup.cs, My

... public void ConfigureServices(IServiceCollection services)


        services.AddScoped<IUserRepository, UserRepository>();

DBContext I use

using Microsoft.Data.Entity;
using IBM.Data.Entity;

namespace DB2.Models.Users
    public class UserContext: DbContext
        public DbSet<User> User { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

My collection

using System.Linq;

namespace DB2.Models.Users
    public class UserRepository: IUserRepository
        private UserContext _context;

        public UserRepository(UserContext context)
            _context = context;

        public void pass()
            var x = _context.User.First();            

This error appears when the line "var x = _context.User.First();" is executed:

System.BadImageFormatException was unhandled by user code
    FileName=IBM.Data.DB2, Version=, Culture=neutral, PublicKeyToken=7c307b91aa13d208
    FusionLog==== Pre-bind state information ===
LOG: DisplayName = IBM.Data.DB2, Version=, Culture=neutral, PublicKeyToken=7c307b91aa13d208
LOG: Appbase = file:///C:/Users/JOlivas/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: No application configuration file found.
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: IBM.Data.DB2, Version=, Culture=neutral, PublicKeyToken=7c307b91aa13d208
LOG: Fusion is hosted. Check host about this assembly.
LOG: Try host assembly store with assembly, version=, culture=neutral, publickeytoken=7c307b91aa13d208, processorarchitecture=x86.
LOG: Try host assembly store with assembly, version=, culture=neutral, publickeytoken=7c307b91aa13d208, processorarchitecture=msil.
LOG: Try host assembly store with assembly, version=, culture=neutral, publickeytoken=7c307b91aa13d208.
WRN: Host assembly store does not contain this assembly.
LOG: Attempting download of new URL file:///C:/Users/JOlivas/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update1/bin/IBM.Data.DB2.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

    Message=Could not load file or assembly 'IBM.Data.DB2, Version=, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. An attempt was made to load a program with an incorrect format.
        at IBM.Data.Entity.Storage.Internal.Db2SqlConnection.CreateDbConnection()
        at Microsoft.Data.Entity.Internal.LazyRef`1.get_Value()
        at Microsoft.Data.Entity.Storage.RelationalConnection.Open()
        at Microsoft.Data.Entity.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
        at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
        at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
        at lambda_method(Closure , QueryContext )
        at Microsoft.Data.Entity.Query.Internal.QueryCompiler.<>c__DisplayClass18_1`1.<CompileQuery>b__1(QueryContext qc)
        at Microsoft.Data.Entity.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
        at Microsoft.Data.Entity.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
        at System.Linq.Queryable.First[TSource](IQueryable`1 source)
        at DB2.Models.Users.UserRepository.pass() in D:\Proyectos\MVC\NSEL\DB2\src\DB2\Models\Users\UserRepository.cs:line 16
        at DB2.Controllers.HomeController.test() in D:\Proyectos\MVC\NSEL\DB2\src\DB2\Controllers\HomeController.cs:line 33
4/4/2016 8:36:46 PM

Popular Answer

Do you mean an IBM I or an iSeries? I see you marked db2400. If so, it has a unique DB2 version. If the aforementioned is accurate, utilize the software that comes with IBM I Access for Windows and make mention of the following:

IBM Client Access is located at C:Program Files (x86). IBM.Data.DB2.iSeries.dll

It's possible that the installation is in a different directory. You will have access to this when you do this.

4/1/2016 9:44:23 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow