tareqimbasher / NetPad

A cross-platform C# editor and playground.
MIT License
1.09k stars 56 forks source link

Could not compile data connection assembly CS7013 #190

Closed surfmuggle closed 2 months ago

surfmuggle commented 3 months ago

I just discovered and started to use NetPad. I tried to create a connection string but got the error

Could not compile data connection assembly. Compilation failed with the following diagnostics: (56,20): error CS7013: The name "<...

Steps taken

Problem

Expected

Possible cause of the error

Running this

SELECT type, name, tbl_name, rootpage, sql  FROM sqlite_master;

returns

type name tbl_name rootpage sql
table a a 2 CREATE Table "a" (....

The sql looks like this but with about 5000 rows

CREATE TABLE "a"(
"Model;Chassis no. ;Chassis no. 17-digits;SomeDate;Invoice_No;Invoice date;Support;Anfrage 1
a;b;c;d;e;f;g;h;
a;b;c;d;e;f;g;h;
a;b;c;d;e;f;g;h;
...
;;;;;;;
;;;;;;  241.223;
;;;;;;;
...
;;;;;;;
;;;;;;;
;;;;;;;
" TEXT)

Running SELECT * FROM a returns 0 rows.

NetPad Screenshot

My NetPad 0.7 looks like this NetPad_error

tareqimbasher commented 2 months ago

Hello. I'm trying to replicate the issue. Can you provide me with the SQL to create the table a? The error CS7103 typically means that the name of property or member exceeds the maximum length allowed. You mentioned when you run:

SELECT type, name, tbl_name, rootpage, sql  FROM sqlite_master;`,  the SQL for table `a`

is:

CREATE TABLE "a"(
"Model;Chassis no. ;Chassis no. 17-digits;SomeDate;Invoice_No;Invoice date;Support;Anfrage 1
a;b;c;d;e;f;g;h;
a;b;c;d;e;f;g;h;
a;b;c;d;e;f;g;h;
...
;;;;;;;
;;;;;;  241.223;
;;;;;;;
...
;;;;;;;
;;;;;;;
;;;;;;;
" TEXT)

If that's true, then it seems you somehow have that huge string as a column name. In that case, when EF Core scaffolds your database it will generate a property name that is very long, thus giving you the CS7013 error.

surfmuggle commented 2 months ago

The Create statement is similar to the one above. But after rereading this i would close or even delete this issue since the underlying cause is that the CREATE TABLE statement is incorrect. I do not remember how exactly this table was created - probably while attempting to import a csv file. But the csv file did not match rfc4180 but used a ; as a separator. My assumption is that the sqlite cli command to change the separator .separator ";" did not work as expected.

surfmuggle commented 2 months ago

It may be better to delete this issue so that others do not stumble over this none netpad issue.

tareqimbasher commented 2 months ago

Thank you for the update @surfmuggle!