-
Notifications
You must be signed in to change notification settings - Fork 36
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
Scaffold warning message in one-to-one relationship tables #241
Comments
Can I ask, what version of Efcore.Jet are you using, what .Net version? Also are you able to share the whole scaffold command line? Are you specifying any tables as part of that command line to include? |
Yes, you can! EFCore.Jet: 7.0.3 The command line:
I'm using Any CPU as the platform target and "Microsoft.ACE.OLEDB.12.0" provider just in the scaffold project, in the real project I use x86 as the platform target and "Microsoft.Jet.OLEDB.4.0" as the provider. |
If I understand this properly, in Just looking at the error message, there is one thing that stands out. The principal table name is Having a look where it is read, see EntityFrameworkCore.Jet/src/EFCore.Jet/Scaffolding/Internal/JetDatabaseModelFactory.cs Line 498 in 7181427
it almost looks like the relation/foreign key isn't set up properly. It would help if you could show the design view of the parent and child in MS access, or preferably link to a copy of the database itself (perhaps a minimal db with just a parent and child table in it) |
I attached a minimal db, 'Modelo.mdb' inside 'Modelo_mdb.zip': The parent table is Funcionarios (Employees), the child table is FuncionarioDocumentos (EmployeeDocuments), the key field that relates both tables is FuncionarioID (EmployeeID). Inside MS Access, when I display relationships, I get: I also checked the MSysRelantionships system table within MS Access and there is this row: Using that command line I showed in this database, I still get the same message:
|
Thanks for the sample database, helped heaps. Ultimately, we can ignore this warning. The generated code is fine
And the
A bit of background on what is happening.
It's a fairly easy fix to make sure AdoX only returns results for the foreign keys when getting the relations in the database (primary keys and unique are dealt with elsewhere). It should make its way into the 8.0 series coming up shortly but the 7.0 series won't be updated. It's really just a difference of a result row not being returned at all, or the result row being returned and then being skipped with a warning when we get to that row |
Thanks for the clarification and keep up the good work! I'm happy to be able to help in some way. |
My database has a main parent table with some child tables with a one-to-one relationship. So, ParentTable has a primary key in a ParentId field, and all ChildTables also have a ParentId field, and all these child tables have a foreign key in the ChildTable.ParentId field and also a primary key in the same ChildTable.ParentId field.
When I run the Scaffold-DbContext command line on my database, for each of these child tables I get this warning message:
Is it expected or some kind of bug?
I was unable to find information about this message.
Despite this, the code that is generated seems fine:
Although now I noticed that the ParentId field was created as nullable in the ChildTable.
The text was updated successfully, but these errors were encountered: