问题
Has anyone used .NET Core with DB2 and EF Core? We've tried to find compatible drivers, but none seem to exist. Has anyone found a way to use DB2 with .NET Core 3.0?
Thank you!
回答1:
There is no core 3.0 or standard 2.1 support thanks to IBM's terrible .Net support. Supposedly an alpha driver will be available in March 2020 if you contact their support.
You can some of the conversation at this link.
回答2:
IBM have now released a new version 3.1.0.300
of IBM.EntityFrameworkCore
on nuget that works with EF Core 3.1.
A couple of things I needed to do for it to work:
- Download new version of license file that targets DB2 version 11.5 from passport
advantage
- I don't know why this limitation exists, but our old 11.1 license simply did not work and the database was not upgraded at all.
- License file must be copied to
C:\Users\{YourUserNameHere}\.nuget\packages\ibm.data.db2.core\3.1.0.300\buildTransitive\clidriver\license
- For older versions, replace
buildTransitive
withbuild
- For older versions, replace
I'm assuming the user has access to the IBM Passport Advantage, I don't know about trial licenses.
It was quite confusing to find where to download the license file, but I figured it out and will mention the steps here for anyone else who needs to do it:
- Determine which version of license is needed, in this case 11.5
- Go to: https://www.ibm.com/support/pages/downloading-ibm-db2-version-115-linux-unix-and-windows
- Find the correct part number for you from the list, for me it was CC6XNML.
- Use the part number in the Passport Advantage software downloads page
- Instructions: https://www.ibm.com/support/pages/node/99203
- After that just download the lic file and place it in the library nuget installation directory mentioned above.
Note: It's still possible to use the older library with .NET Core 3.1, as long as EF itself is not updated to the 3.1 version. The problem is compatibily with EF 3.1, not .NET Core 3.1. As long as updating the EF nuget package to a newer version is avoided, things will work just fine.
回答3:
There are packages for Db2 listed on the Database Providers EF Core help page. I haven't used them, personally, but if they're listed there, they should work fine.
来源:https://stackoverflow.com/questions/59270598/using-entity-framework-with-net-core-and-db2