views:

63

answers:

1

In one of my current projects we keep running into this very wierd problem with Linq-to-Sql:

If we update some properties of some objects (that are mapped to the db) and then SubmitChanges as usual, we are not able to see these changes until we rebuild the entire solution in visual studio.

How come?

A: 

I assume your LINQ objects are in a different project? And that you are referencing that project in the code that ends up calling SubmitChanges? It is entirely possible that the code is using the previously built version of the project dependency, and therefore the version without your changes. If you right-click on your executing project in the solution explorer and select "Project Dependencies", make sure that the dependent LINQ project you have is checked off on that list. Similarly, on the second tab of the dependencies window is Build Order. Your LINQ project should be built before the project that depends on using it.

EDIT: I've seen this problem in the past before where the reference LINQ project was reference by DLL instead of "by project". You might delete the reference and then re-add it, making sure you do so via the "projects" tab.

Matt
Thanks! This may actually be the solution, however I am running into some problems... When trying to untick the DAL (project with my Linq2Sql-classes) in Project Dependencies: "This dependency was added by the project system and cannot be removed". When trying to change build order: I simply can't. It says "Use the Dependencies tab to change the build order" and I tried that as well with no success. Any suggestions?
Mickel
You don't happen to have any circular dependencies going do you? Does your DAL project reference your running project and vice versa? You wouldn't think this is possible, but it is if you do references by browsing by DLL instead of by project.
Matt
Oh, and why are you unticking DAL if it is a dependency?
Matt
Ok, looks like I misunderstood what you wrote: "make sure that the dependent LINQ project you have is checked off on that list". The executing project has the DAL-dependency checked in Project Dependencies. There is no circular dependencies either. All dependencies are referenced by projects, not DLLs. :/
Mickel
Found one way to make it work, but I still don't know what went wrong... First I removed all connection-strings that was automatically generated by the context, added to app.config etc. to then use a more collected approach (see http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/). Then I changed from using inline code to get/edit (by creating a new context) the items to using methods in my BLL (as it was intended to from the beginning).
Mickel
Interesting - not sure how those changes fixed the problem for you, though I'm glad it did!
Matt