in

how to regenerate code when you change the database structure

Last post 05-09-2008 5:12 PM by Justin_W. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 03-13-2008 8:04 PM

    how to regenerate code when you change the database structure

    Hi

    I am having problems regenerating my subsonic classes now i have changed my database structure. I have deleted a column called AssetName and I am now getting this error

     

    Unable to set column value for AssetName

    [Exception: Unable to set column value for AssetName]
       SubSonic.AbstractRecord`1.Load(IDataReader rdr) in C:\SVN\Subsonic\SubSonic\ActiveRecord\AbstractRecord.cs:467
       SubSonic.AbstractList`2.Load(IDataReader rdr) in C:\SVN\Subsonic\SubSonic\ActiveRecord\AbstractList.cs:154
       SubSonic.AbstractList`2.LoadAndCloseReader(IDataReader rdr) in C:\SVN\Subsonic\SubSonic\ActiveRecord\AbstractList.cs:179
       SubSonic.AbstractList`2.Load() in C:\SVN\Subsonic\SubSonic\ActiveRecord\AbstractList.cs:310
       Tracking_TrackingMap.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\SureTrack2\Tracking\TrackingMap.aspx.vb:17
       System.Web.UI.Control.OnLoad(EventArgs e) +80
       System.Web.UI.Control.LoadRecursive() +49
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745
    

     

    This is what i did to try and regenerate the code

     Firstly i went to my subsonic project and re-ran the subcommander tool. This didnt seem to work properly as i looked at my classes and they did not reflect the fact the column name has been deleted in the class properties. So i deleted all the generated classes and ran the sub commander again. This time the classes seemed to reflect the changes. Then i went to the website to try and update the new subsonicgenerated.dll. There was no 'update reference' which i'm used to seeing so I deleted the reference to try and add it again. Once i deleted it i could not add the reference from the projects tab and i had to add the reference by browsing to it. Then i ran my page and got the error above suggesting the assetName column is still in the code.

     

    thanks in advance for your help

    andrea

  • 03-13-2008 8:14 PM In reply to

    Re: how to regenerate code when you change the database structure

    me again

     i deleted all the generated classes and the subsonicgenerated.dll in teh website and ran the subcommander tool again and everything works ok now but i'm sure it isnt necessary to do this when you change the database structure. what is the correct waay to regenerate classes

     thanks

    andrea

  • 03-13-2008 11:55 PM In reply to

    Re: how to regenerate code when you change the database structure

    You can try the build provider if you want the site to regenerate the classes when you change it (Note: you might have to nuge it sometimes)
    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk
  • 03-23-2008 4:52 PM In reply to

    Re: how to regenerate code when you change the database structure

    Hi Thanks for your reply but I don't know what it means. I dont know anything about build providers - i just use the tool as shown on the instructional videos

    Please can you explain how i would use the build provider

  • 03-23-2008 9:26 PM In reply to

    Re: how to regenerate code when you change the database structure

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk
  • 03-26-2008 2:34 PM In reply to

    Re: how to regenerate code when you change the database structure

    Hi I'm sorry but I still don't understand

    According to the first video i watched on how to set up a subsonic website it tells you to delete the abp file in the app code directory so I'm not sure how you use the build provider to regenerate code after the database has changed. I understand how you generate code the first time but after that i don't understand

    thanks

  • 03-26-2008 4:28 PM In reply to

    Re: how to regenerate code when you change the database structure

    Don't delete the abp file, open it up, modify its contents and re-save.  This could be as simple as adding a space. 

    The build provider looks for changes to this file so by making a change to the file will force the build provider to execute which should then update your objects reflecting the changes you made to your DB.

  • 03-26-2008 4:36 PM In reply to

    Re: how to regenerate code when you change the database structure

    Also, when using the subsonic.exe to gen your classes, you may need to click on the refresh button at the top of Solution Explorer to see the changes.   

  • 05-09-2008 5:46 AM In reply to

    Re: how to regenerate code when you change the database structure

    Hi

    I tried adding the subsonic.abp file back to the app_code directory and now the website won't compile. There are 300 errors. Normally so many errors happen when something small and daft is wrong don't they!

     

    thanks

  • 05-09-2008 12:33 PM In reply to

    Re: how to regenerate code when you change the database structure

    andieje:

     i deleted all the generated classes and the subsonicgenerated.dll in teh website and ran the subcommander tool again and everything works ok now but i'm sure it isnt necessary to do this when you change the database structure. what is the correct waay to regenerate classes

    Andrea,

    Were your existing generated class files Read Only when you tried to regenerate? If you have them loaded into source control, they probably were. If so, you don't have to delete all of them to regen, just change the files to writable beforehand.

    Justin

  • 05-09-2008 12:40 PM In reply to

    Re: how to regenerate code when you change the database structure

    Hi

    I'm not really sure what you mean so please feel free to talk to me like I'm an idiot. I looked at the properties for the generated classes in Visual Studio and there was nothing there that said about read/write permissions. I went to the folder where they are created and looked at the security tab. The files have 3 users: administrator, everyone and system. All 3 users have all permissions ticked except special permissions. However I can't edit the permissions for any user either as they are greyed out.

    thanks

    andrea

  • 05-09-2008 1:06 PM In reply to

    Re: how to regenerate code when you change the database structure

    1. Open the file system folder containing the genned class files. 2. Open the file/folder properties. 3. Look at the CheckBox labeled "Read-only". Uncheck it if it isn't already. 4. Click OK. Hope that helps.
  • 05-09-2008 1:44 PM In reply to

    Re: how to regenerate code when you change the database structure

    Did you delete all the files you generated with SubCommander or SubStage (if you used them)
    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk
  • 05-09-2008 2:46 PM In reply to

    Re: how to regenerate code when you change the database structure

    Hi Justin The generated folder has the same 3 users as the individual files. For each user all of the properties are greyed out so i can't change them but read and write permissions are checked. I cant see anywhere that specifically has a read-only checkbox. I'm using windows xp and will never move to vista :)
  • 05-09-2008 5:12 PM In reply to

    Re: how to regenerate code when you change the database structure

    It's not on the Security tab, it's on the General tab (towards the bottom).

Page 1 of 1 (15 items)