-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
Enable getting views from schema query (for EF Core 3.0) #233
Comments
Sure thing. Do you have an example Create view statement and its expected code generation? Probably won't need it, but nice for verification |
It is just for reverse engineering, and this is just the first, inactive baby step. The new fluent property is .HasNoKey() |
My part for MySQL is already showing views in the list actually, but it is showing them up as "This table has no primary key and will be ignored", so I am unsure if there's more to be done for me? |
@jespersh great. The message is a UI issue. |
@roji Ping? |
Sorry for not responding on this. @ErikEJ this is about having EFCore.PG scaffold views right (like dotnet/efcore#1679)? If so I've opened npgsql/efcore.pg#972 to track and will probably complete this for preview8. Thanks for poking me on it :) |
So it turns out I'm getting senile, and already did this (npgsql/efcore.pg#878). Is there anything else you need from me here? |
@roji No, I meant this: https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/EFCorePowerTools/Helpers/EnvDTEHelper.cs#L192 - this should be updated to also include views |
@jespersh There is not "VIEW" object in MySQL? https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/EFCorePowerTools/Helpers/EnvDTEHelper.cs#L275 |
@ErikEJ I can easily pick out the data here: https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/EFCorePowerTools/Helpers/EnvDTEHelper.cs#L244 |
It has a HasPrimaryKey property => views have no primary key! |
So what do you wish for to do with tables without a primary key? |
The can now be scaffoled as Entities with not key (HasNoKey) |
@ErikEJ can you please provide more details on exactly what you need? Npgsql exposes view information via the "views" schema collection, in a way that seems to be compatible with the way SqlClient does it. Let me know what exactly is missing and I'll look into it. |
@roji thanks, I will just implement the changes myself |
Ok @ErikEJ, let me know if you need anything from my side. |
@ErikEJ yep, that looks like it should work! Let me know if you hit any issues with it. |
@roji thanks, I will let some Postgres users test it! |
@roji Any ideas in relation to this: "// TODO: Check if the table has a primary key" ? |
Hmm... I don't know exactly what your code does, but you can have tables with and without primary keys - that may be important (or not). However, AFAIK in PG views cannot have primary keys (or any kind of constraint), so this may just be a copy-paste. |
@roji I mean: how do I detect if a table (not a view) has a primary key? |
I think you need to get a different metadata schema. Looking at the source, getting "CONSTRAINTS" or possibly "CONSTRAINTCOLUMNS" should be it (not in front of my computer so can't dig deeper)... |
@roji are you able to get the latest daily and test this? https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/EFCorePowerTools/Helpers/EnvDTEHelper.cs#L203 (I do not have a server installed) |
@ErikEJ I can try to find some time during this week, but it's gonna be tight (dotnetos conference). But it's super easy to install PostgreSQL and test stuff: https://www.postgresql.org/download/windows, I'd rather help you do that |
@jespersh That looks like a bug in the latest daily build! (I am working on EF Core 3.0 support) |
Should be fixed now (2.3.48 or later) |
@jespersh I really appreciate that you are running the latest daily build! |
I tried with 2.3.49.0 and got the same window. Can't select regular tables with primary keys.
should:
|
That is correct! What am I doing wrong? |
I think I found the bug! 😊 |
Wait, are these new? EFCorePowerTools/src/GUI/RevEng.Shared/TableInformationModel.cs Lines 55 to 64 in cc23919
I notice that "_isKeyless" is the inverse of "HasKey", so which is it? :-) For mysql am I just setting
|
And you can delete these lines: EFCorePowerTools/src/GUI/EFCorePowerTools/Helpers/EnvDTEHelper.cs Lines 251 to 254 in 8d40124
They appear to have no effect and I don't remember why I put it twice. Think a mistake was made that I always included views in the list, but it never bothered me. |
Just noticed you added it yourself :-)
|
@jespersh Does the latest daily fix it? |
@ErikEJ I don't see a mysql related commit after #233 (comment) |
Doh - never pushed the fix - just did it now! |
It works again. Thanks! |
If EF Core 3.0, get at concatenated list of:
1: tables sorted by named
2: views sorted by name
The text was updated successfully, but these errors were encountered: