Unique key's not generated anymore

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 15-Dec-2012 14:50:44   

Using : LLBLgen 3.5 final (17 march), SQLSErver 2008R2

Hello,

I just wanted to move a version of our app to another environment, but when I create the SQL script of our database using "Create Database schema Create Script (DDL SQL)" , the unqie constraints are not included. I'm sure this worked before, because when I look into our source control where we keep previous scripts, the unique indexes were included.

As a test, I created a brand new LLBLgen project, connected to the DB , added all tables and saved the llblgenproj file. If I look in the llblgenproj file and search for "IX_", I only find 2 unique indexes (while we have dozen's). It looks like this in the llblgen proj file :

              <UniqueConstraints>
                <UniqueConstraint Name="IX_ResultList">
                  <Field Name="Name" />
                </UniqueConstraint>
              </UniqueConstraints>
            </Table>

These 2 unique constraints are also the ones created in the DDL SDQL script. but all the others are gone ? If i look in the original database with SSMS, I see no difference why the unique index on those two tables are included in the LLBLGen project, and all the others are not ...

Please help ...

EDIT: my bad; It seems the previous scripts were generated with SSMS and not with LLBLGen. Furthermore, the two uniques that are included in LLBLGen are really unique KEY while all others are unique INDEX (and for some reason, LLBLgen skips this, but the SSMS script generation does not ..)

releases on saturdays are always fun ...

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Dec-2012 06:43:21   

If you refresh the catalog from your DB and then export the Create DDL, Does it work? AFAIK, LLBLGen doesn't manage indexes.

Should we consider this closed? or Do you have additional questions/inquires?

David Elizondo | LLBLGen Support Team
kakaiya
User
Posts: 166
Joined: 20-Mar-2004
# Posted on: 02-Jul-2024 05:42:39   

Hi,

Somehow can not create a new thread so did the search and asking.

I am using .NET 8.0 CORE, VS2022 and latest LLBLGen.

When I am using bucket to filter using primary key then I get 'this' populated to count = 1

 IRelationPredicateBucket bucket = new RelationPredicateBucket();

 bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiEODSiteId == eodSiteId);
 bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiIsDeleted == false);

ISortExpression sorter = new SortExpression();

 using (DataAccessAdapter adapter = new DataAccessAdapter())
 {
     adapter.FetchEntityCollection(this, bucket, 0, null, null, null);
 }

after FetchEntityCollection executed I can see this count = 1.

But on same table we have unique index, when filter by below

bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiEODSiteURLFrom == eodSiteURLFrom);

this count = 0 and SQL 22 Server Profiler show query OK but data is not in this object (which is IEntityCollection2 collectionToFill)?

if I use below method to fetch data at entity level as it has unique constraint

success = adapter.FetchEntityUsingUniqueConstraint(this, uniqueConstraintFilter, prefetchPath, contextToUse, excludeIncludeFields);

then it does not fetch so I get below message.

'this.EsiABN' threw an exception of type 'SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException'

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39689
Joined: 17-Aug-2003
# Posted on: 02-Jul-2024 09:07:20   

kakaiya wrote:

Hi,

Somehow can not create a new thread so did the search and asking.

Creating a new thread is done on the Forum page, e.g. https://www.llblgen.com/tinyforum/Forum/10/1 and then click the + icon at the top right of the threadlist.

I am using .NET 8.0 CORE, VS2022 and latest LLBLGen. When I am using bucket to filter using primary key then I get 'this' populated to count = 1

 IRelationPredicateBucket bucket = new RelationPredicateBucket();

 bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiEODSiteId == eodSiteId);
 bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiIsDeleted == false);

ISortExpression sorter = new SortExpression();

 using (DataAccessAdapter adapter = new DataAccessAdapter())
 {
     adapter.FetchEntityCollection(this, bucket, 0, null, null, null);
 }

after FetchEntityCollection executed I can see this count = 1.

But on same table we have unique index, when filter by below

bucket.PredicateExpression.AddWithAnd(DAL.HelperClasses.InkEODSiteFields.EsiEODSiteURLFrom == eodSiteURLFrom);

this count = 0 and SQL 22 Server Profiler show query OK but data is not in this object (which is IEntityCollection2 collectionToFill)?

Now you have 3 predicates in the predicate expression, so the entity matching EsiEODSiteId == eodSiteId && EsiIsDeleted == false also has to have EsiEODSiteURLFrom == eodSiteURLFrom. If not 0 rows will be returned.

if I use below method to fetch data at entity level as it has unique constraint success = adapter.FetchEntityUsingUniqueConstraint(this, uniqueConstraintFilter, prefetchPath, contextToUse, excludeIncludeFields); then it does not fetch so I get below message. 'this.EsiABN' threw an exception of type 'SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityOutOfSyncException'

If you save an entity and then read from it, it's out of sync, or when you have a new entity and read from it you get the same exception. So please look at the stack trace where the exact error occurs.

These are all different problems so please focus on 1 problem at a time simple_smile

Frans Bouma | Lead developer LLBLGen Pro
kakaiya
User
Posts: 166
Joined: 20-Mar-2004
# Posted on: 02-Jul-2024 10:34:23   

Hi Otis,

Thank you. I am using your tool for many many years. Its really nice tool.

Debugging - will post again if issue persist - please wait ....

Sorry - OK now.