Renaming tables

Posts   
 
    
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 15:19:43   

I am having troubles with renaming tables. For example I have one table called Subject. The old name was Repository_Subject_tbl and we stripped off the prefix and suffix. We refreshed the catalog, deleted the old entity, added the new Subject entity, and everything was mapped OK. We regenerate the code and everything was fine because we had LLBL strip off the prefix and suffix in the past so the object names stayed the same. We are able to call up entities and collections, but when we save an entity, we get an error message that the Repository_Subject_tbl table does not exist. I can't figure out where it's getting the old name from as it doesn't exist in the code anywhere. We created a whole new project in an empty directory and tried that and still it is looking for a table name that doesn't exist anymore.

It's weird that we can retrieve data but not save it.

Where does the actual mapping of the entities to the tables exist?

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 10-Jul-2007 15:26:11   

Hi,

What version of llbl do you use?

did you specify any prefix in your config file?

Could you post your lgp file?

Do you use adapter or selfservising ?

If you use adapter, mapping of the entities are stored in PersistenceInfoProvider.vb in the dbspecific project.

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 15:38:22   

Sorry I should have included that in my first post.

LLBL version 2.0.0.0 September 8th, 2006

Self Servicing - Two Classes 2005

Using VS 2005 VB.Net and SQL Server 2005

I don't specify any prefix in a config file

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 15:40:49   

I tried attaching my lgp file, but it is too large.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 10-Jul-2007 16:21:28   

Hi,

first of all, could you update to the last build of llbl v2.0 (2006 is a little old). How many your file is large?

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 16:31:56   

It's 735 K

Where do I get the latest version?

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 10-Jul-2007 16:38:28   

The table mappings reside in the PersistenceInfoProvider file (dbspecific project in adpater scenario). If in any case you can't solve the problem some other way, you could still perform a find/replace in that file.

Still you should try to: - check in the designer's entities Edit tab if the mapping are correct (should be) - properly delete the corresponding code file or enable file edit (source control issue?) so that the generator can overwrite it

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 10-Jul-2007 16:40:33   

Hi,

go to http://www.llblgen.com/. Login with you client id and password. Select download for v2.0 and then download the latest version.

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 16:46:56   

I downloaded the latest version (June 18, 2007) and am installing it.

I checked the PersistenceInfoProvider class and the prefix Repository_ is not in there and the mappings look correct.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 10-Jul-2007 16:59:52   

Hi,

did you use any caching mecanism? In debug mode, could you find where the prefix come from?

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 17:06:34   

We are using no caching mechanism that I am aware of. We created a new empty directory to create the generated code in so there would be no effect from any previous code.

We have searched through all of the code and there is no instance of the old table name. In debug mode everything looks great until the save is called on the base class.

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 10-Jul-2007 19:45:21   

Here is the Exception message:

"An exception was caught during the execution of an action query: Invalid object name 'dbo.Repository_Subject_tbl'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."

Here is the inner exception:

{"Invalid object name 'dbo.Repository_Subject_tbl'."} System.Data.SqlClient.SqlException: {"Invalid object name 'dbo.Repository_Subject_tbl'."} Data: {System.Collections.ListDictionaryInternal} HelpLink: Nothing InnerException: Nothing Message: "Invalid object name 'dbo.Repository_Subject_tbl'." Source: ".Net SqlClient Data Provider" StackTrace: " at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()" TargetSite: {System.Reflection.RuntimeMethodInfo}

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Jul-2007 10:42:55   

1- Would you please try to re-attach the LGP file again (zipped if you want)? 2- How do you perform the save action? using a normal an entity, or a SP? 3- When You are doing the save, Would you please examine the generated Query, and manually run it against the database. (ref: manual "Using the generated code -> Troubleshooting and debugging")

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 11-Jul-2007 13:05:36   

1 - I am attaching it zipped

2 - I am using an entity object save method

3 - Here is the SQL I captured in SQL profiler:

exec sp_executesql N'UPDATE [Repository].[dbo].[Subject] SET [HostIdent]=@HostIdent,[LastUpdate]=@LastUpdate WHERE ( [Repository].[dbo].[Subject].[SubjectId] = @SubjectId1)',N'@HostIdent varchar(50),@LastUpdate smalldatetime,@SubjectId1 int',@HostIdent='a',@LastUpdate='2007-07-11 06:48:00:000',@SubjectId1=1964

I executed it manually and SQL Server returned this error:

Msg 208, Level 16, State 1, Procedure SubjectUpdateDateLastUpdated, Line 7 Invalid object name 'dbo.Repository_Subject_tbl'.

So it looks like LLBL is doing what it's suppose to, any idea what SQL Server is doing?

The table Repository_Subject_tbl doesn't exist anymore and I looked in the system tables and find no trace of the old name.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Jul-2007 15:17:32   

From the query you have posted it's obvious that LLBLGen Pro is not doing anything wrong. So check your database, maybe you have a trigger using the old table name.

Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 11-Jul-2007 15:31:31   

I had 2 small triggers on this table with the wrong name in them.

Thanks for the help!