This project is read-only.

Removing Objects

Mar 16, 2010 at 5:57 PM

Hi,

When I remove a view from the designer then generate, the (view related) generated code files do not get removed from tha DAL.  I have to remove them manually, also the update script does not remove it from the server so I have to remove that manually too.  Is this behaviour by design to stop things being removed accidentally?

Thanks,

Rob

Mar 17, 2010 at 2:22 AM

This is one of the caveats. Adding, deleting and edit fields is handled and adding. Also adding and removing relationships is handled. However tables, stored procedures, and views is not handled. This is quite intentional. We really do not want to remove tables (and by extension data) from someone's database accidentally. In the pre-generate SQL scripts just adding the remove statement. You really need only to add 2 lines an "if exists..." and the actual remove statement. This way we know you meant to delete one of the high level objects. I know it is a little annoying but we figured that it would not happen too often and the risk of people deleting important data seemed worth it.

Also keep in mind that files are never removed from your VS.NET solution. This is also intentional. So if you have a Customer table and in your solution you have files generated like "Customer.cs", "Customer.Generated.cs", "CustomerCollection.cs", "CustomerCollection.Generated.cs", etc you will have to remove them from your project manually. This reasoning behind this is that people can and do write custom code and we did not want to remove files from disk that could have custom code in them.