-
Notifications
You must be signed in to change notification settings - Fork 40
Using 'System.Data.OleDb' on 'net472' throws 'TypeLoadException' #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@xoniuqe How are you referencing OleDb in the project file? Originally posted by @ChrisJollyAU in #34 (comment) |
@ChrisJollyAU Yes I did. I will upload a demo project on my github. https://github.com/xoniuqe/Ef-Core-Jet-TypeLoadException Originally posted by @xoniuqe in #34 (comment) |
@xoniuqe Do you specifically need the full .net framework? Changing your demo to use .net core 3.1 is a possible solution Originally posted by @ChrisJollyAU in #34 (comment) |
@ChrisJollyAU I have dependencies to .net Framework assemblies which are not usable in .net core 3.1, so yes. Originally posted by @xoniuqe in #34 (comment) |
@xoniuqe I tried adding a binding redirect but didnt work. I can see in the debug as it loads, it loads the correct version but at runtime the .net framework version keeps on getting picked. Should probably open a issue specific for this Originally posted by @ChrisJollyAU in #34 (comment) |
Here's the problem. The netstandard version includes all the OleDb classes whereas the .net framework version doesn't. It in turn references the normal System.Data @lauxjpn The OleDb bug that was in the net core version, do you know if that was only in net core? If so on the full framework you can ignore the version check. Tried without the version check and it goes further but I do get a COM error when it tries to create the database using DAO Originally posted by @ChrisJollyAU in #34 (comment) |
@xoniuqe I tested my changes and it does work on your test project. It will just use the OleDb classes from the framework's System.Data rather than the nuget package. Also I would recommend changing your connection string to use ACE rather than Jet. Jet is quite old and only supports database formats up to around access 2003. Creating a new database will use DAO which will use the current access runtime installed. If you are using e.g the 2010 or 2016 runtime, it will be created in that format which is not supported when using the Jet connection string. Should only need to change the Provider to Have it working in both x86 and x64 |
@ChrisJollyAU Thank you for the fast work, unfortunalety I think I have to stick to the Jet driver because we currently have the requirement to work with the old database format. But I give it a try and will give you an update. But this has to wait until monday. |
Okay, the issue is fixed with #84. I had no serious issue with the test project that @xoniuqe provided when using #84, but only a minor one regarding the double quotes surrounding the |
@xoniuqe Jet should still work. if you already have a database |
@lauxjpn Is it really necessary to do the version check like that versus adding it as a nuget dependency requirement? |
@ChrisJollyAU We have the nuget dependency requirement in We could make it mandatory for people to install either What we don't want is to add |
@lauxjpn What about removing the |
We currently have a mechanism that just infers the data access library needed from the connection string used. So if I currently specify There is also the possibility to just specify the filename and nothing else, which will use the default data access provider (currently ODBC), or to specify just the file name and an enum value, that states what data access provider to use. Up until 3.1, people have been using the We could get rid of the the inference feature if it is not needed (and adjust our testing system). People would than have to write their own logic to switch between ODBC and OLE DB. We could also probably change the filename-only feature to check which library, If we want to get rid of the |
You actually have some internal usage of UseJet within |
@ChrisJollyAU Yes, if we would go forward with this proposal, we would need to adjust the code generation for the As for dependent files on While it is generally a good idea to move the ODBC and OLE DB dependent code into their own packages (see #45 (comment)), I don't think we should touch it for 3.1 anymore, because of the still not great unit test situation and the fact that the current implementation does work. |
I could use this strings on the 2.2.X version, is this a newly introduced bug? |
@xoniuqe Yes. 3.x is nearly a complete rewrite and now also allows the usage of ODBC (previously only OLE DB). As a quick workaround, do not use explicit double quotes around your path in the connection string. |
@lauxjpn: This worked kind of. I can load the mdb file successfully with the removed quotes, but when I try to migrate I get an OleDBException "Unrecognized database format error"(may not be the exact wording). If I change the provider to |
@xoniuqe Not sure about the database password. However I did mention something about that unrecognized database format error earlier in this issue. In summary the new file is created using DAO from the currently installed access engine (e.g. in the test suite for this project it uses the access 2010 engine). However when trying to read it using OleDb, you are specifying the Jet OleDb driver which is too old to understand the 2010 format. The ACE OleDb driver can understand that format. As an aside the wikipedia article has a nice table of the drivers and which formats each support. https://en.wikipedia.org/wiki/Microsoft_Jet_Database_Engine |
We should fix this. We should provide an option to specify the database version that should be used. I will push a PR for this. @xoniuqe Regarding the password: Your sample code uses the However, you can just call JetConnection.CreateDatabase("test.mdb", databasePassword: "PASSWORD"); Or together with context.Database.EnsureDeleted();
JetConnection.CreateDatabase("test.mdb", databasePassword: "PASSWORD");
context.Database.EnsureCreated(); |
@xoniuqe This issue is fixed with #91. As far as I am aware, we should now have fixed all issues reported by you. So if I missed anything, please remind me again. |
@lauxjpn After a short test with my prototype everything seems to work as I would expect it. Thank you for your fast responses and the fixes. Great job! (@ChrisJollyAU thank you too, you were also helpful). When I first was evaluating to use this provider for our ancient software I was a bit sceptical (at first the project seemed a bit inactive to me, to be honest) but I must admit im really impressed by the handling of my issues here 👍 |
Hello, I tried to get the prerelease package working in a net 5 project. Didn't work. Tried downgrading to 3.1 core, also didn't work |
Hi @jeromv . Net 5 is not supported yet. It does require a fair number of changes to be built against it. It should be working for .net core 3.1 . Can you post your project file and the exact error message you're getting |
Thanks
I get Method 'get_Info' in type 'EntityFrameworkCore.Jet.Infrastructure.Internal.JetOptionsExtension' from assembly 'EntityFrameworkCore.Jet, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
This the project file
Can’t upgrade to the prerelease, I get a version conflict when I try to
Cheers
Jeroen
From: Christopher Jolly <[email protected]>
Sent: zondag 28 februari 2021 14:31
To: bubibubi/EntityFrameworkCore.Jet <[email protected]>
Cc: jeromv <[email protected]>; Mention <[email protected]>
Subject: Re: [bubibubi/EntityFrameworkCore.Jet] Using 'System.Data.OleDb' on 'net472' throws 'TypeLoadException' (#83)
Hi @jeromv <https://github.com/jeromv> . Net 5 is not supported yet. It does require a fair number of changes to be built against it.
It should be working for .net core 3.1 . Can you post your project file and the exact error message you're getting
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#83 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADCZCMDDPQPB3SW2WAZL5FDTBJASVANCNFSM4ULDWBLQ> . <https://github.com/notifications/beacon/ADCZCMCMNCFL54ADA5JFS4TTBJASVA5CNFSM4ULDWBL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF3XZFPY.gif>
|
You need the prerelease. The version you are using is 2.2.0 which is compatible with net core 2 Your project file is not included If your project file uses packagereferences have this as a line in it
|
Did a screenshot of the project file sorry 😊
These are the references I use (froegt about the sqlite…)
<PackageReference Include="EntityFrameworkCore.Jet" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3">
When I try to upgrade to theprerelease I get
Version conflict detected for Microsoft.EntityFrameworkCore.Relational. Install/reference Microsoft.EntityFrameworkCore.Relational 5.0.3 directly to project DuikLogBoekEF to resolve this issue. DuikLogBoekEF -> Microsoft.EntityFrameworkCore.Tools 5.0.3 -> Microsoft.EntityFrameworkCore.Design 5.0.3 -> Microsoft.EntityFrameworkCore.Relational (>= 5.0.3) DuikLogBoekEF -> EntityFrameworkCore.Jet 3.1.0-alpha.4 -> Microsoft.EntityFrameworkCore.Relational (>= 3.1.10 && < 5.0.0).
From: Christopher Jolly <[email protected]>
Sent: zondag 28 februari 2021 15:28
To: bubibubi/EntityFrameworkCore.Jet <[email protected]>
Cc: jeromv <[email protected]>; Mention <[email protected]>
Subject: Re: [bubibubi/EntityFrameworkCore.Jet] Using 'System.Data.OleDb' on 'net472' throws 'TypeLoadException' (#83)
You need the prerelease. The version you are using is 2.2.0 which is compatible with net core 2
Your project file is not included
If your project file uses packagereferences have this as a line in it
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#83 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADCZCMAWRMZWOOYSDO4IHJLTBJHFHANCNFSM4ULDWBLQ> . <https://github.com/notifications/beacon/ADCZCMDXIA6YTTZIYD6CNOTTBJHFHA5CNFSM4ULDWBL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF3X3ICI.gif>
|
Ah, your version is wong for all those starting with
3.1.12 is the latest in the 3.1 series. If you have all those change to use that version and have
You may want to add either Also, it would be best to downgrade the |
Thanks. Will try that
From: Christopher Jolly <[email protected]>
Sent: zondag 28 februari 2021 15:43
To: bubibubi/EntityFrameworkCore.Jet <[email protected]>
Cc: jeromv <[email protected]>; Mention <[email protected]>
Subject: Re: [bubibubi/EntityFrameworkCore.Jet] Using 'System.Data.OleDb' on 'net472' throws 'TypeLoadException' (#83)
Ah, your version is wong for all those starting with Microsoft.EntityFrameworkCore . Being version 5 they are referencing the net 5 version of those packages
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12" />
3.1.12 is the latest in the 3.1 series. If you have all those change to use that version and have
<PackageReference Include="EntityFrameworkCore.Jet" Version="3.1.0-alpha.4" /> for EFCore it should work
You may want to add either EntityFrameworkCore.Jet.OleDb or EntityFrameworkCore.Jet.Odbc depending on whether you prefer oledb or odbc style connection strings (and behind the scenes access)
Also, it would be best to downgrade the Microsoft.EntityFrameworkCore packages first before going to the correct EFCore version
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#83 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADCZCMEIL2A22LGT2NR3J5TTBJI7NANCNFSM4ULDWBLQ> . <https://github.com/notifications/beacon/ADCZCMD4JHZE45JZLQH6ALLTBJI7NA5CNFSM4ULDWBL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF3X3ZQQ.gif>
|
Works!
Version="3.1.12" was the clue. Thanks for your help, much appreciated!
From: Christopher Jolly <[email protected]>
Sent: zondag 28 februari 2021 15:43
To: bubibubi/EntityFrameworkCore.Jet <[email protected]>
Cc: jeromv <[email protected]>; Mention <[email protected]>
Subject: Re: [bubibubi/EntityFrameworkCore.Jet] Using 'System.Data.OleDb' on 'net472' throws 'TypeLoadException' (#83)
Ah, your version is wong for all those starting with Microsoft.EntityFrameworkCore . Being version 5 they are referencing the net 5 version of those packages
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12" />
3.1.12 is the latest in the 3.1 series. If you have all those change to use that version and have
<PackageReference Include="EntityFrameworkCore.Jet" Version="3.1.0-alpha.4" /> for EFCore it should work
You may want to add either EntityFrameworkCore.Jet.OleDb or EntityFrameworkCore.Jet.Odbc depending on whether you prefer oledb or odbc style connection strings (and behind the scenes access)
Also, it would be best to downgrade the Microsoft.EntityFrameworkCore packages first before going to the correct EFCore version
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#83 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADCZCMEIL2A22LGT2NR3J5TTBJI7NANCNFSM4ULDWBLQ> . <https://github.com/notifications/beacon/ADCZCMD4JHZE45JZLQH6ALLTBJI7NA5CNFSM4ULDWBL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF3X3ZQQ.gif>
|
@lauxjpn: I am not sure if the implementation is buggy or if I do something wrong, but when trying to load my database via oledb the version I provide with nuget gets ignored and I get the TypeLoadException from JetFactory. The call of Type.GetType(...) seems to be problematic, if I load the System.Data.OleDb via Assembly.Load(..) the correct one gets loaded, but Type.GetType(...) uses the default for my target framework (in this case net472). Should I open up a bug or is this my fault?
Originally posted by @xoniuqe in #34 (comment)
The text was updated successfully, but these errors were encountered: