Live Fast, Code Hard, Die Young

One thing I find quite annoying in Visual Studio is when I try to modify an existing database table and get the following error dialog that prevents me from saving:

image

“You cannot save changes that would result in one or more tables being re-created”

So, what the heck is up with that? This seems to appear when you move columns around or change the “Allow Nulls” setting. I know I could do this in earlier version of Visual Studio so why can’t I do it anymore? Yes, I know I’m changing the table structure fundamentally but I know what I’m doing and it should be safe to do it – just let me save please!

Well, the wall of text in the dialog actually tells you what to do. You have to enable this in the VS options. For some reason this is disabled by default and my guess is that it is to prevent people who have no clue what they are doing from destroying the database schema…

Anyway here is where you find the option that you should disable. It is called “Prevent saving changes that require table re-creation”:

image

Does this mean that you entire table data will be erased when you make a change? No, certainly not! All it means is that your data will be copied to a temporary table and then copied back when the table has been altered. I guess this is how it has always worked but before you never had to bother about it – it just worked.

Well, thanks to this little option it now works again!

Advertisements

Comments on: "Altering database tables with VS2010" (4)

  1. I didn’t find this option in tools>options …(1)
    But i found it in debug>options …(2)

    I use vs 2010 express

    After cleaning, as you say, but with (2) it works!

  2. Thanks for pointing this out. I’m not using VS2010 express myself so I didn’t know 🙂

  3. Thanks @Pontus.. Save me alot of time here!

  4. Ljupco said:

    Thank you Adrian.

    (2) worked for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: