Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> How do I refresh data from the database if there are missing primary keys in the existing data?
 

Pages: 1
Bugs & Issues
How do I refresh data from the database if there are missing primary keys in the existing data?
Page:1/1 

  Print all messages in this thread  
Poster Message
JMitchell
User



Location:
Leeds, England. Generally using VB.NET 2008, LLBLGen 2.6, Self Servicing
Joined on:
01-Sep-2006 10:34:36
Posted:
128 posts
# Posted on: 03-Sep-2010 12:33:06.  
I have migrated a 2.6 project. I tried to generate the code but it seems tables missing primary keys now give errors and stop you generating the code.

Fair enough, I've removed two un-necessary tables and added primary keys to the others.

When I right click on SQL Server (SqlClient) through either Relational Model Data in the Project Explorer or via the Catalog Explorer and click Refresh Relational Model Data from a Database, it gives me the same errors about the missing primary keys I have created in the database.

How should I proceed?
  Top
JMitchell
User



Location:
Leeds, England. Generally using VB.NET 2008, LLBLGen 2.6, Self Servicing
Joined on:
01-Sep-2006 10:34:36
Posted:
128 posts
# Posted on: 03-Sep-2010 14:05:27.  
I removed the problem tables and added them back in afterwards. I still think this needs to be looked at though.

  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37405 posts
# Posted on: 03-Sep-2010 18:02:47.  
JMitchell wrote:
I removed the problem tables and added them back in afterwards. I still think this needs to be looked at though.

Every entity mapped onto a table requires to have 1 or more identifying fields. In v2.6 we didn't force that upon users, in v3 we do.

After a converted project you might fall into the trap that you can't refresh. So do the following:
- for the entities which give you this error, select 1 field and mark it as the identifying field. YOu can do that in project explorer, by right-clicking the field, or by opening the entity in the entity editor.
- click 'validate and adjust relational model data'. This will set the target field in the table information as PK.

You now have two options:
1) export the DDL SQL and apply it to the schema in your database. (recommended). This thus makes the table have a pk. You can now refresh OK.
or
2) set in project properties the setting 'IdentifyingFieldsFollowDBPrimaryKeyConstraints' to false. When you now refresh you'll get a dialog which shows you 3 options: export, abort or ignore the export. Click this last option. Then refresh normally.

The second option has the problem that you will have to manually assign PK fields. So it's recommended to have each table in your db to have a PK.

If you use these tables as readonly tables anyway, it might be a good idea to map a typedview on them instead of an entity (new in v3). The code you use in your project is a little different, but it doesn't force a PK on you, and as you use the data in a read-only fashion anyway, it's perhaps more fitting your domain.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 12-Dec-2013 14:41:51.  
Frans,
I appologize for being critic here. I'm a database first kind-a-guy ...

When a problem is detected in the database, which prevents proper generation, then the expected sequence is to fix it in the database and refresh the datamodel.

That ought to fix it right???

Paul





  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37405 posts
# Posted on: 13-Dec-2013 10:06:20.  
Pablo wrote:
Frans,
I appologize for being critic here. I'm a database first kind-a-guy ...

When a problem is detected in the database, which prevents proper generation, then the expected sequence is to fix it in the database and refresh the datamodel.

That ought to fix it right???

That would make it not detect the problem (if I understand you correctly) indeed.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 14-Dec-2013 20:28:04.  
Otis,
The problem is that it does not.

When i ran into this problem, it turned out a rather frustrating experience, namely ..
fixing it in the database dit not do anything to enable llblgen designer to refresh the model from the database...

My first solution was to delete all entities from the project and refresh again etc.
My current solution is to fix the problem twice ... once in the databas, then in the entity in the designer ... and than i'm able to refresh the model again from the database.

Now, being aware of a 'working' workaround, it is ok ... it still feels rather stupid though. If you could fix it, I'd appreciate it very much (I'm sure others will be too)!

Paul




  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37405 posts
# Posted on: 16-Dec-2013 10:58:46.  
What's the specific problem you ran into? I can't fix things I don't know the specific details of Regular Smiley

The general idea is that if the db has a problem, it's not OK to refresh the project as that might have devastating results for the project which you then have to correct manually. So we opt for not refreshing when you run into a problem.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 16-Dec-2013 17:33:27.  
Which problem to solve ... fair enough!
I'll open a new issue.


  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.