LINQ TO SQL Sync / Refresh Tables in Designer?

I ran into my first problem with LINQ TO SQL a couple of days ago and forgot about it. I ran into again today and decided to let everyone know about it.

What I ran into was if you change an underlying table in SQL Server there is not a way to "refresh" or "sync" the table in the LINQ TO SQL Designer. The only way to get the updated table is to delete the current table from the designer and then add it again to the designer.

A significant problem with this method is if any of your stored procs have a return type of the table being deleted you have to change the return type before deleting the table (or delete the proc and add it in again). For instance if you have a User table and one of your stored procs have the return type of User the table cannot be deleted.

At this point it's not so terrible that I don't want to use it anymore but I'm looking to Microsoft to fix this problem pretty quickly as it's a very ugly "feature".

Technorati Tags: ,,.NET 3.5

posted @ Thursday, January 17, 2008 11:25 AM

Print

Comments on this entry:

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Hilton Giesenow at 2/24/2008 3:07 AM
Gravatar
This is a tricky one because Microsoft can't assume you haven't made custom changes on the designer. I'm enjoying working with LINQ To SQL, but I'm not sure I'm all that happy with the designer approach at the moment. One way to get around this, by the way, is to drag another copy of the table onto the designer, copy-paste the changes over to the original entity, then delete the new duplicate table.

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Chris at 2/24/2008 9:52 AM
Gravatar
I suppose that's true but I'm not opposed to a message stating that the entity about to be deleted was customized and will lose those customizations when deleted.

MS guys are smart enough to be able to figure out how to store custom changes differently than the original table design.

I think they will fix this one next release. Or at least I hope so. :-)

I like your idea and will try it out. Although it doesn't solve the issue of the original entity not being able to be remove if it's a return type of a proc.

Thanks for the comments,

Chris

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Jon Kruger at 3/6/2008 9:37 PM
Gravatar
I don't want to hear an MS excuses on this one.

1) They obviously know what properties I've changed because they show up as bold in the Properties window
2) DataDude can detect changes between two versions of a database object just fine

Seems to me that they could put these two together pretty easily.

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Chris at 3/6/2008 10:33 PM
Gravatar
Yeah this is pretty lame. I'm hoping they fix this. In fact David Dewinter has started to do something similar:

http://dev.rev-net.com/blog/ddewinter/?p=41

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Kristofer at 8/20/2008 6:32 AM
Gravatar
I have written an add-in for Visual Studio that adds the missing "refresh"/"update" from schema, "compare to schema" etc. It comes packaged with add-ins for mass-updating the entity and member names for both Linq2SQL and EF generated models...

More details (and download link etc) at http://www.huagati.com/dbmltools/

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Dan-El at 6/1/2009 10:05 AM
Gravatar
Check out http://www.codeproject.com/KB/linq/LINQ_to_SQL_Database_Sync.aspx"
An open source utility that synchronizes your database structure with a LINQ to SQL model.

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by jouer blackjack au casino at 12/12/2009 6:23 AM
Gravatar
I have really mixed feelings, LINQ's CRUD stuff is pretty nice and relatively easy to work with. I have built my own hybrid entity layer some time back and I can tell you it saves a huge amount of time during development to not have to deal with CRUD issues. But it's not as consistent as I'd like it to be and I've been for a long time waiting to plug a more robust entity engine into it. And LINQ's implementation of the basic CRUD functionality is pretty nice and the code it generates is reasonably clean.

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Shared Web Hosting at 12/20/2009 12:38 PM
Gravatar
Good work

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by flash messenger at 12/28/2009 7:23 AM
Gravatar
I am really enjoying reading your well written articles. It looks like you spend allot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Web designers at 1/3/2010 7:28 PM
Gravatar
Thanks for great stuff!

# LINQ TO SQL Sync / Refresh Tables in Designer?

Left by health insurance at 1/16/2010 7:00 AM
Gravatar
Wow! i agree! i’ve been searching for so long for a site where i could find everything that i want, and i’ve just found it!! really, i’ve visited your blog, and it’s amazing, i will keep visiting

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Love poetry at 1/17/2010 8:43 AM
Gravatar
I like your idea and will try it out. Although it doesn't solve the issue of the original entity not being able to be remove if it's a return type of a proc.

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Mike O'Neill at 2/16/2010 5:55 AM
Gravatar
Hi

I see above Kristofer has mentioned the Huagati tool , this works wonderfully and is constantly adding extra features to make it even more useable.

Also maybe look at Codesmith's PLINQO templates , they rebuild the dbml file from teh db Schema at each generation , then builds a set of BLL manager classes based on the dbml its created -- works REALLY well but needs a Codesmith license (which is NO BAD THING !!)

My approach is half and half , I use Huagati to sync the Db and Model and I have created Manager classes based on db Schema using Codesmith , it gives me the best of both worlds and allows me to code the Managers my way

Mike

# re: LINQ TO SQL Sync / Refresh Tables in Designer?

Left by Link Building Service at 3/3/2010 5:27 AM
Gravatar
great share thanks for this

# LINQ TO SQL Sync / Refresh Tables in Designer?

Left by web development at 3/7/2010 8:07 PM
Gravatar
I thought about writing an add-in to do this. My approach would be to update the dbml file. I ran into a couple of issue when looking into this. First, there doesn’t appear to be any public API/object model for the dbml file format. This can be solved by creating my own, but it would be really nice to have a API be public. Second, the designer seems to output some the attributes in a proprietary manner. The PropertyType attribute is one of them. It’s value looks something like this AAEAAAD/////AQAAAAAAAAA… If it weren’t for the proprietary attribute values, it wouldn’t be too hard to create an add-in to update the model. Is there some way to generate that value, is it some sort of hash?

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 3 and type the answer here:
 

Live Comment Preview:

 
«March»
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910