25. August 2008 16:41
Be very careful when you need to recreate your entities with Linq to SQL. If I added a new column to the table and I needed to refresh my entity I used to remove it from the design and re add it again. This has worked for a while until now when all of a sudden I started getting errors in my production environment. What happened? I used to have the property DeleteOnNull on an association and when I removed the associated entity to recreate it it also removed the association. When I added the entity back to the diagram the association was recreated automatically, but the DeleteOnNull property was not set. Of course I realized what has happened a little too late and I found my self fixing a bug. How can you avoid this problem (besides having a bunch of unit tests)? I will say that if you need to refresh the entity, simply modify it manually with whatever changes you have made in the data base. That way you will not loose any property you might have added.
SP 1 of the .NET Framework 3.5 was recently released and having a refresh feature in the diagram would have been very nice