Regenerating code causes exception on compilation when changing a view

Posts   
 
    
Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 31-Oct-2007 14:13:11   

If have 5 views in my DB (SQL 2005). 2 I added today. On refreshing the catalog I'm able to select the new added views. But the strange thing is these views (which are called vw_Oa and vw_RetourOa), appear as Oa_ and RetourOa_ in LLBLGen. Nothing strange here, I have set the prefect as vw_, the only strange thing is these two typed view have both a underscore at the end. I think that is strange because the other three don't have this underscore. But that is ok.

The problem is when I add a field to one of these views and i do an unattendent refresh the names of the last two added views are changes to Oa and RetourOA (without the underscore at the end). Now when I regenerate the DAL, I receive the exception "The namespace 'xxxx' already contains a definition for 'OaFieldIndex'" (the same exception for the RetourOA part) It comes from the ContantsEnum.cs file.

To solve the problem I first have to delete the typed views in LLBLGen and then add them again. They appear in the list again followed by the underscore as described. Now when I regenerate everythings works fine.

I work with LLBLGen 2.5, .NET 2.0 using selfservicing.

I have set the option to clean the project file on regeneration, so that is not the solution. I think this is a bug. Also maybe someone could explain me why the views so with an underscore at the end.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Oct-2007 16:19:22   

I think you have been re-mapping those views into your project.

When you map an object for the second time LLBLGen by default appends an underscore to its name to avoid Name collisions with the one mapped earlier, then you can re-name it to anything else that you wish, if you really wanted to map that object twice.

Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 31-Oct-2007 16:34:06   

Hi Wallee,

but the underscore was there already when I added the views the first time. When I do the DB Refresh, then the underscore disappears. That is exactly the other way around.

I still don't get is. I mean: 1. Change the view in the DB 2. Refresh 3. The views in LLBL are renamed (to the once without the underscore) 4. When generating the code, the trouble starts as described before 5. Delete the views from LLBL 6.Choose add new from Catalog (where I can see the views I deleted including the underscore) 7. Regenerate again. No problems

I would say this is a bug, but easy to workaround. I just wanted you to know. It could be I'm doing something wrong, but what?

Thx

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Oct-2007 17:13:12   

I can't reproduce it. Could you attach a repro lgp project file, with the corresponding database script?

Are you mapping those views as TypedViews or as Entities? When you say you see an underscore, is this in the Project Explorer tree (objects already mapped) OR in the Add New Entities/Typed views window?

Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 31-Oct-2007 17:22:28   

Hi Wallaa,

I use typed views. As for your second question, I'm not sure what the difference is, but I right click on the type view to add new views. There these views already have an uderscore attached.

I will generate the DB script and attach the LLBLGen project and script here.

Let me know

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Oct-2007 17:42:47   

but I right click on the type view to add new views. There these views already have an uderscore attached.

Alright this explains some simple_smile

I think these views were already mapped as entities. An yet you have the option to re-map them as TypedViews, but the underscore is appended to avoid naming collisions, specially when it comes to Field Indexes.

To try it out: 1- Map a view as an entity. 2- Try to Map the same view as a Typed View.

Or the other way around.

Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 31-Oct-2007 18:16:31   

Aha, Now I see,

the views where not added as entities, but the name of the view is the same name as an entity.

I have a table called TBL_OA and a view VW_OA

When stripping the prefixes TBL_ and VW_ then we have two object with the same name.

This explains the the naming. But isn't it a bug when I refresh, the current views are renamed to views without the underscore. Which are then conflicting with the current entities? I would say in that case the names shouldn't be changed. I mean the view should keep its underscore at the end.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Nov-2007 10:02:33   

I'll try it out.

(EDIT)

Unfortunatly I couldn't reproduce it. I'm using the "September 24th, 2007" version of the Designer.

Based on your steps:

  1. Change the view in the DB
  2. Refresh
  3. The views in LLBL are renamed (to the once without the underscore)
  4. When generating the code, the trouble starts as described before
  5. Delete the views from LLBL 6.Choose add new from Catalog (where I can see the views I deleted including the underscore)
  6. Regenerate again. No problems

Here is what I did: 1- Created a table named tbl_AB 2- Created a view that has nothing to do with the above table, the view is names vw_AB 3- Created an LLBLGen project mapping the table as an entity -> mapped name (AB) 4- Mapped the view as a TypedView -> mapped name (AB_) 5- Refreshed the catalog., nothing changed, the entity and the view still retain their names. 6- Changed the view in the database, adding another field. 7- Refreshed the catalog., nothing changed, the entity and the view still retain their names.

Am I doing something wrong here? What's your LLBLGen Pro Designer release date? (Help->About)

Stephan
User
Posts: 63
Joined: 16-Jan-2007
# Posted on: 02-Nov-2007 18:37:25   

Hi Walaa,

August 20th 2007, may be this is the cause.

An other thing: I set the "SynMappedElementNamesAfterRefresh" this keeps the names in their original state.

So that is also useful I think.