-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: support .NET EntityFramework Core and Scaffolding tool #48050
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I have CC'd a few people who may be able to assist you:
If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
This comment has been minimized.
This comment has been minimized.
Thanks for the issue! I am still building up my knowledge of EF Core, so sorry for the delay. @roji do you have any insight into what could be going wrong here? If you would be able to take a look and help us investigate, please let us know if something could be wrong/missing from the CockroachDB side. |
The Npgsql EF Core provider sends some queries against PostgreSQL catalog tables to inspect existing tables etc. - I'm guessing CockroachDB has some subtle incompatibility with PostgreSQL here. The query for getting the columns is here. The stack trace seems to indicate that the problem is with a |
@roji Thank you! That's very helpful. The However, we have a project underway to make our catalog tables compatible with newer versions of Postgres, although the details of which versions/columns we are going to be adding soon are still being determined. @lemonway I've made this issue to track adding these columns #48541 In the meantime, it's possible that Npgsql could account for these missing columns as part of this issue in that project: npgsql/efcore.pg#1360 |
@rafiss yeah, that makes sense. These are already conditional on on the version. However, I'm a bit curious how the query managed to run at all - at least in PostgreSQL if you try to select a column that doesn't exist (e.g. |
As a general rule, would it make sense to say that UseCockroachDb (npgsql/efcore.pg#1360) should set PostgreSQL compatibility mode to 9.5? That would propagate to the relevant places automatically, instead of adding CockroachDB-specific checks. |
That's a good point. I ran the query against CockroachDB myself, and noticed that there is one more So it must be that column that is causing the issue. In retrospect this should have been more obvious to me -- the issue here must be that in CockroachDB,
I think that would be a good starting point. There may be additionally functionality that CockroachDB does support, but if needed, perhaps later on we can add a check for CockroachDB specifically where it would be relevant. |
OK, that all makes sense now :) Yeah, PostgreSQL |
Ah actually, sorry it doesn't seem like So the issue is coming from the constant cast expressions in the query: And indeed, comparing the results of |
@rafiss Oh yeah, you're right - I'm assuming @lemonway user configured the provider for an old PostgreSQL (to avoid exactly erroring on attidentity not existing in the database), but my query still generates a fake empty column with the same name and type. typtype doesn't actually get read by Npgsql so it shouldn't be a problem. I'll simply cast attidentity/attgenerated to text in my query to avoid reading |
One question before I look at this change... these catalog tables have some other somewhat exotic types. For example, pg_constraint uses |
CockroachDB does handle the |
OK, I'll make the change (npgsql/efcore.pg#1362). Hopefully @lemonway will be able to help us verify there aren't any other issues. We can keep this issue to track any other problems until we see it working. |
FYI the change has been made on my end for 3.1.4, hopefully that's the only thing blocking scaffolding. @lemonway (or others), can you please add the Npgsql stable feed and try out version 3.1.4-ci.20200509T114251 of the provider? It would be great to know if everything works now. |
Hello, I'm @lemonway user.. (I've accidentally use the account of my company) FYI @rafiss: "I'm assuming @lemonway user configured the provider for an old PostgreSQL" => No, as you can see all the steps in the description, there isn't any step which change any configuration in particular.. You can just copy paste these same command lines step by step to create an empty project and got this error. @roji : it is true that the generator actually uses the latest stable version of Npgsql.EntityFrameworkCore.PostgreSQL which is currently 3.1.3 Where can I find the 3.1.4 dll? (on Nuget I saw only 3.1.3 and 5.0.0-preview..) It will be my pleasure to try it out. |
@duongphuhiep 3.1.4 isn't released yet. However, our CI produces nuget packages for every commit we do, which allows you to easily test before 3.1.4 comes out. Take a look at the details in the above comment (#48050 (comment)) and let me know if anything is unclear. |
@roji with the error message changed
|
@rafiss the relevant code is here, can you take a quick look? If nothing comes to mind, how easy is it for me to get access to an instance (or quickly set one up locally)? |
Thanks @roji. I ran the query used by Very excited if you'd like to try locally -- It is very easy to get started:
|
I'll try to give it a go in the next few days. |
List of issues specifically for scaffolding (@rafiss we can track here or elsewhere):
|
@rafiss have opened some issues currently blocking scaffolding. The above can be worked around in the driver, i.e. by disabling the specific features (i.e. catching exceptions and moving on). I've opened issues to let you know of the gaps though. |
Thank you @roji! That is very helpful. Working around in the driver seems like the ideal step for now. We will get to these issues as lower-priority items over the next few months. We can use this issue to track progress (I will rename the title, and move your checklist into the main issue description). |
Noting that all of the checkboxes in this issue are now solved. Do we need to re-test with a newer build? |
I want to use Cockroach with c# and Scaffolding, but this error occurs:
anyone knows about it? |
These are the known issues needed to fully support all EntityFramework Core features
Original Issue Description
Describe the problem
The EntityFramework has a Scaffolding tool which allow to generate C# (Plain-Old Class Object) from database in the Database first approach.
It works well for a Postgres Database, but not for a CockroachDB.
In this example, I created a "tg" database in Postgres and a "tg" database in CockroachDB using one same SQL Script.
To Reproduce
Requirement:
dotnet tool install --global dotnet-ef
"Server=127.0.0.1;Port=26257;Database=tg;User Id=root;"
Step to reproduce error:
Expected behavior
C# POCO class shoud be generated in the
model/tg
folderError
Environment:
Additional context
Cannot use database first approach for CockroachDB
Jira issue: CRDB-4362
Epic DXTPT-33
The text was updated successfully, but these errors were encountered: