-
Notifications
You must be signed in to change notification settings - Fork 40
Unofficial EF Core 6 support #111
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
@bairog If you feel like it, give the attached a try. They are currently a work in progress. The EF5/Net5 is at the exact stage the the .Net 5 pull request is at. Compiled from my net5structure branch https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net5structure Unzip to the project and manually add as reference. If you prefer a nuget package, you may have to wait for @lauxjpn to finish the tests and merge so that it will show in the nightly builds Originally posted by @ChrisJollyAU in #98 (comment) |
@ChrisJollyAU Thank you for your work. Database that I need to query has a lot of specific: table names are Cyrillic, tables has no primary key, colums names are Cyrillic. My entites and DbContext in a .NET 6.0 class library
My code to read data from ASP .NET Core 6.0 Web App
I've compiled it but get the following error in runtime at
I've added a nuget reference for latest System.Data.OleDb 6.0.0 to a class library project and now I have the following error on
Stack trace
After that I've tried to reverse engineer my existing MS Access database as advised in wiki.
Stack trace
In MS docs there is only Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger for EF Core 5.0, not for EF Core 6.0. Originally posted by @bairog in #98 (comment) |
You might be missing some references Originally posted by @ChrisJollyAU in #98 (comment) |
@ChrisJollyAU Originally posted by @bairog in #98 (comment) |
I don't see any thing related to Jet in the stack traces. Looks like it's just around in ef core. Also, not sure what you're trying to do with the scope and serviceProvider. That's how I do it in my console program. Then just use context as normal Originally posted by @ChrisJollyAU in #98 (comment) |
@ChrisJollyAU
Ok, I will try to perform a test with "traditional" MS database (with English table names and column names) - maybe that is the core of the problem here... Originally posted by @bairog in #98 (comment) |
@ChrisJollyAU Originally posted by @bairog in #98 (comment) |
Actually, might have the same problem on ef6. It is experimental right now. Also perhaps should have a separate issue for ef6 experimental stuff Originally posted by @ChrisJollyAU in #98 (comment) |
I changed the title to Unofficial EF Core 6 support, since we will not make any official advances towards EF Core 6 until the EF Core 5 supporting release is out. |
Cool. @lauxjpn Looks like I have the same problem as you had here dotnet/efcore#26260 |
Yeah, there are a couple of hiccups when upgrading to 6.0. |
@lauxjpn Think I've got it working now. Some things in the JetQuerySqlGenerator I had to comment out. It just uses the base function for now til I have another look at redoing it for the functionality it had without using the sqlexpressionfactory @bairog If you feel like it give the attached a try. Looks like it works. Have only done 1 test on it though. Just a basic entity query (Standard disclaimer - this is pre-alpha experimental) |
@ChrisJollyAU I've tested the attached libraries in my console application with .net6.0-windows7.0 TFM. |
I have submitted a pull request that compiles and is based on the v5.0.0-alpha.1 tag with dependencies updated to latest versions & targets .net6. |
Any update about the official release for .net6? 5 months ago v5.0.0-alpha.1 is on nuget and it's not compatible with EF 6 (actual 6.0.6). Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 6.0.6 directly to project XXX to resolve this issue. |
Any update on this? Or even .net 5? |
I'm trying to make the provider work in .net 6 and there are several changes between frameworks. I changed the ConfigureDesignTimeServices method to make it look similar to the one in SQL Server provider, and introduced JetCSharpRuntimeAnnotationCodeGenerator which implements ICSharpRuntimeAnnotationCodeGenerator. I'm testing with a simple model creating a couple of tables with a primary key and a foreign key, and for some reason when I do an Add-Migration call, it works but misses 2 things in the generated migration class: 1.- Annotation("Jet:Identity", "1, 1") is not added to the primary key in the "columns" property at CreateTable calls (it was being generated correctly on .net 5 provider) I wonder if someone knows what I could be missing to handle those 2 items on new services introduced for .net 6 entity framework. Maybe some developer could guide me to know which class was the responsible of adding those annotations, I think it may be something related with JetAnnotationCodeGenerator, but cannot figure which method is needed to be overriden to make those 2 properties work. Another usefull info is that if I run the Migration class generated by .net 5 provider using .net 6 build it creates the tables, primary keys (autoincremental) and foreign keys perfectly, which leads me to think that this is only a problem with the Migration class generation/scaffolding. Any help will be appreciated! I know there are no plans for .net 6 support untill .net 5 build is out, however maybe it could help to have a .net 6 branch to work on it, since .net 5 is not supported anymore by Microsoft. @lauxjpn, if you think my contributions may help, you can create a .net 6 support branch and I can make a pull request on this branch with all my changes that doesn't make a full working build at all (like .net 5, not all unit tests are working because lot of them need a redesign), but I think is a good start because it supports basic functionality, and compiles with .net 6.0.8, and maybe someone from the team could help to improve it. |
I have got "Disable savepoint API, because it is not supported by Jet" issue while using EFCore.Jet.NET6 codebase. In general (on first glance, after a few tests with sample Nortwind database) EFCore.Jet.NET6 seems to be working rather well. It would be helpful to have EF Core 5 and EF Core 6 merged with EF Core 6 becoming the main codebase. |
Which repo are you using? https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6 ? |
@ChrisJollyAU That would be great! I have y working copy updated to latest packages for 6.0.9 |
@nicovil I have just checked - downloaded .zip archive from https://github.com/ChrisJollyAU/EntityFrameworkCore.Jet/tree/net6. |
@ ChrisJollyAU It would be great! I'd be waiting for your fixes! |
@nicovil @ChrisJollyAU Yes, net 6.0.9 as the target .NET (Core) version would be the best option. |
Here is a short wish list for EFCore.NET.6.0.9+:
It would be useful if .IsClustered(...) fluent API call would be just ignored by EFCore.JET6.
so it currently has to be commented out: For example:
Images are (usually) stored in MS Access files with 'OLE Object/Long Binary Data' data type.
is not properly loaded when DbContext's OnModelCreating() method used .IsRowVersion() and .IsConcurrencyToken() API calls, e.g:
when .IsRowVersion() and .IsConcurrencyToken() are commented out then data is properly loaded and saved to MS Access database.
to be ignored by EFCore.Jet.6.0.9+ to have the same DbContext code working with MS Access and MS SQL backends without conditional compilation or run-time backend-type checks to bypass code not supported by certain backend types. |
@nicovil @ShamilS I've had a look and have updated to 6.0.9 (although if your project was directly referencing 6.0.9 it would be using that as what it is compiled against is set as the minimum required version). I've also merged the fixes from the master branch into my code. I will note that I haven't gotten to any tests yet. All I know is that it compiles without errors. Will probably be able to do some stuff tomorrow/this week Also, @ShamilS I will see if there is anything I can do about your points. Some will be easier than others |
@ChrisJollyAU Transactions work now. Thanks! |
Yes, I have checked it works, generates expressions for DateTime field type with milliseconds as, e.g
Thank you for clarification. |
@nicovil Are you sure it was working in the 5.0 series? It's just that I found a test that looked like it has the same problem (the And nothing further in the fluent API section. In both the 5.x and 6.x code the Even using the Obviously the test was failing as it expected the The only place where the From https://learn.microsoft.com/en-us/ef/core/modeling/keys?tabs=data-annotations#value-generation
can see that setting a numeric primary key to the identity is the expected situation. Looking at how Sqlite does it I have updated Those tests now work so hopefully your problem should be fixed A couple more tests were also fixed
|
Hi @ChrisJollyAU , I'm pretty sure it works because I'm using the migration generated class from 5.0 build with my 6.0 working copy. Are you adding the "HasKey" fluent definition too? This is the code that I'm using, and 5.0 generated the migration correctly.
Did you pushed the changes to your repo? I'm going to test your last changes to confirm they work. |
@nicovil Any chance for the full class for the table and the OnConfiguring section for that table for the Fluent API part. So that I can try a test on my side as well |
@nicovil Any update? Is it working now? Also are you still having the problem with the foreign keys or is that fixed as well? |
@ChrisJollyAU Hi Chris, sorry for the delay. Thanks! |
Is there some way to send the Fluent configuration file to you? |
Hi again @ChrisJollyAU. I did a full build from your net6 repo, and tried the Add-Migration command, but sadly I'm getting the same error: Here is the output from Package Manager Console.
|
@nicovil Thanks. It's an interesting problem as I have often had to debug and step through A couple of questions:
|
@ChrisJollyAU , here is more info. If I modify the JetDesignTimeServices class (like I did in my working copy) to this:
Things are working now, and the generated migration code auto incremental (counter) keys has the Annotation("Jet:Identity", "1, 1") calls. The generated empty Access database has the counter data type created correctly. HOWEVER There is an issue that has not been resolved, the "onDelete" configuration. In this snapshot you can see the difference between net 5.0 migration code (LEFT) and 6.0 migration code (RIGHT). I'm not sure, maybe ReferentialAction.Restrict is the default value for onDelete property, and that's why it's not being generated in 6.0 version? |
Here we go: (1) my base system is in Spanish, but it's almost the same output.
(2) Visual Studio 2022 Professional, v17.3.5 (3) Target: AnyCPU, Windows10 (4) Exactly the same behavior than from package management console. |
I really think the issue is in ConfigureDesignTimeServices. If you check the SQL Server provider code, you will notice it changed from EF 5.0 to EF 6.0 and that it's now calling the EntityFrameworkRelationalDesignServicesBuilder helper class, plus also calling the AddXXXXX method to register all services for dependency injection. |
@nicovil Yeah. Was just looking to see if it had anything to do with one part being a different bitness to the other. But it seems fine I've looked at one table that I set the Restrict behaviour to and followed it through its sql generation.
CREATE TABLE I will get a Syntax error in constraint clause error
As to what is happening in your migrations, best guess for now is the .Net 5 is including the detail but when generating the SQL it is not doing anything |
@nicovil Think I have it fixed now.
Running Add-Migration creates the following
This is as expected.
Also, as I expected given that there is no Restrict in Jet |
Hi @ChrisJollyAU . I updated the code from the repo and made a rebuild, everything seems to be working now. The only detail, which I don't think is important, is that I was not explicitly setting up restrict mode for the foreign key. That is, I was not adding the "OnDelete" call in the fluent confuration:
So, in 5.0 it seems that the migration framework was adding this by default. Again, I don't think this is important and having the behavior for explicit fluent configuration that you added is a good thing to have. |
That's a bit odd. Without knowing the full definition it's a bit hard to say though. Normally EF Core will set it up as on delete cascade if nothing else specified |
Here is an example in .net 5.0 to show my point: This fluent code:
is generating this migration code:
|
My tests with your actual version of the code are going very well, and I'm almost sure I'm having the same behavior than with .net 5 build. So, since the actual version seems very stable (equal or even more than net 5.0 version), do you think it's a good time to create a Nuget package (at least an ALPHA release) for .net 6 version? It would be good because lot of people will be testing it there. Maybe it's time to create a .net5 branch (or tag) in official repo and merge your changes into this main repo's trunk to have it as baseline? (just giving my opinion, of course it's your decision since you're part of the official team) |
@nicovil Thanks for the feedback. Good to know that it seems to be working nicely. I'd love to get an alpha .Net 6 release out sometime. Best I can do is create a pull request (probably sometime this week) and get the maintainers that do have access to merge it |
That sounds very good. I guess since you're a contributor they will hear you! |
For those following this thread PR #131 is created |
Awesome work @ChrisJollyAU. |
Similar to the Ef Core 7, I have updated a number of things
At this point in time unlikely to turn on nullable for .Net 6 but maybe in the future |
For all those following, this is now in the master branch |
@ChrisJollyAU Thank you. When approximately we may expect it to be released? |
@bairog Should be on the daily build feed and the nuget feed now. It's still marked as an alpha prerelease. Standard Jet limitations apply |
For those following Beta 1 is now available Notable improvements are:
With the 6.0 series I am just trying to fix the bugs. The 7.0 series is where anything big/new will most likely appear |
Uh oh!
There was an error while loading. Please reload this page.
Created to continue discussion on EF core 6 support that was started here
The text was updated successfully, but these errors were encountered: