EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

Sqlite Code Generation fails

Open statler opened this issue 1 year ago • 6 comments

I am trying to reverse engineer the attached Sqlite db with the given config. It fails with an uninformative warning. I tried debugging the T4, but that bails out after creating the configs for the primitives. Latest version. Any ideas?

Blankv120.zip

statler avatar Mar 06 '24 05:03 statler

Hi Statler, I'm currently on holiday with the family, I'll be back in the country on Monday.

sjh37 avatar Mar 06 '24 08:03 sjh37

OK - so it runs correctly if you use the debug T4 template function in VS, but fails if you try and run it on save.

statler avatar Mar 06 '24 10:03 statler

OK, so it runs, but still generates incorrect configurations. Basically, if a class has multiple FKs to the same table, it will only add the first relationship . I expect that this line is the culprit var constraints = fkList.Select(x => x.FkSchema + "." + x.ConstraintName).Distinct();

Because in the Sqlite config, the schema is identical, and the constraintname is built using the current table and FK Primary key ID, which is also the same. I expect this is a mistake, and the constraintname should include the local property.

statler avatar Mar 07 '24 04:03 statler

Are you planning on fixing this?

statler avatar May 27 '24 05:05 statler

Sorry @statler Yes I am. I'll take a look at this now.

sjh37 avatar May 28 '24 14:05 sjh37

The issue of multiple foreign keys to the same table has been fixed. Thanks for the heads-up on where to look. Foreign keys will have a different name though and will need to be changed in your code after the first run. Download the latest EF.Reverse.POCO.v3.ttinclude

sjh37 avatar May 28 '24 17:05 sjh37

To be released as part of 3.10.0

sjh37 avatar Jan 29 '25 14:01 sjh37