AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

ForeignKey multiple columns are in wrong order! #525

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Link two tables on a FK using 3 columns
2.Generate entities

ThisKey and OtherKey should list the columns in the same order, they didn't

version: PLINQO 5.0.1 (last release at this date)

Original issue reported on code.google.com by guillaum...@gmail.com on 4 Nov 2010 at 11:22

GoogleCodeExporter commented 9 years ago
Can you please see if you can reproduce this in the following nightly build of 
PLINQO(http://community.codesmithtools.com/nightly/PLINQO/plinqo-r2017.zip). If 
you can, could you please send us a sample schema that will reproduce this 
issue along with the lines of code that are being generated incorrectly.

Original comment by bniemyjski on 4 Nov 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Yes I tried the latest nightly build.

I manage to patch the Dbml project to solve my issue, but it's just a hack 
reordering keys by looking at the column names. I don't have time to try to 
reproduce this in a sample project, but I guess if you create these tables you 
should have the issue (SQLServer - order of columns is important)

Table1
======
Col1
Col2
Col3

Table2
======
Col3
Col2
Col1

create a foreign key between the two tables on the 3 columns

Original comment by guillaum...@gmail.com on 4 Nov 2010 at 2:19

GoogleCodeExporter commented 9 years ago
Hello,

Could you please attach a script for creating these two tables and foreign 
keys. I was unable to create all three fk's and I would like to see how your 
indexes and composite keys are configured.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 19 Nov 2010 at 9:01

GoogleCodeExporter commented 9 years ago
hi, 

here's a simple db showing the issue, generate entities and look at ThisKey and 
OtherKey strings in table1.generated.cs

Guillaume

Original comment by guillaum...@gmail.com on 19 Nov 2010 at 9:42

Attachments:

GoogleCodeExporter commented 9 years ago
EDIT: The problem appear with 2 keys as well, as soon as the order is important 
actually

Original comment by guillaum...@gmail.com on 19 Nov 2010 at 9:44

GoogleCodeExporter commented 9 years ago
Hello,

This appears to be generating correctly. I took a look at the foreign key 
constraint as well as the genreated dbml and entity code. Also I checked the 
Microsoft documentation for the definition of ThisKey and OtherKey.

What is being generated for you and do you have a snippet of code that can show 
this breaking? Could you please include the insert statements.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 23 Nov 2010 at 11:05

GoogleCodeExporter commented 9 years ago
I tried to update my PLINQO dlls/templates and I still have this issue (and got 
to patch the dbml.dll again...).

Snippet:
[System.Data.Linq.Mapping.Association(Name = 
"SysDbSourceField_SysDbSourceFilter1", Storage = "_sysDbSourceFilters", ThisKey 
= "DbSourceFieldId,DbSourceSetId,DbSourceId", OtherKey = 
"DbSourceSetId,DbSourceId,DbSourceFieldId")]

Problem:
The ThisKey and the OtherKey columns should appear in a corresponding order, 
it's not the case here (it appears in the declaration in table order I guess).

Original comment by guillaum...@gmail.com on 5 Apr 2011 at 1:37

GoogleCodeExporter commented 9 years ago
Hello,

Would it be possible to get a database backup (no data) that can reproduce 
this.I couldn't reproduce with that database script that was previously used 
which makes me believe that there is extra database metadata that is causing 
this behavior.

Thanks
-Blake

Original comment by bniemyjski on 8 Apr 2011 at 12:13

GoogleCodeExporter commented 9 years ago
Hi,

You're right I tried to isolate the problem in a separate sample DB and it 
disappear.

I'll sent you a backup by email.

Thanks

Original comment by guillaum...@gmail.com on 8 Apr 2011 at 1:07

GoogleCodeExporter commented 9 years ago
Hello,

I'm currently looking into this and will update this as soon as I have more 
information.

Thanks
-Blake

Original comment by bniemyjski on 12 Apr 2011 at 6:35

GoogleCodeExporter commented 9 years ago
Hello,

I restored the database backup and generated against it using the latest 
version. I was unable to reproduce. I searched for all instances of 
"SysDbSourceField_SysDbSourceFilter1" and all the keys were in the same order. 
I than searched for "DbSourceFieldId,DbSourceSetId,DbSourceId" which had no 
results. However, when I searched for 
"DbSourceSetId,DbSourceId,DbSourceFieldId" and compared all of the keys very 
closely they were in the same order. If you generate against this database into 
a new directory does this make any difference?

Thanks
-Blake

Original comment by bniemyjski on 12 Apr 2011 at 9:14