Simply take a row from one datacontext and write it to an identical database table in another datacontext
Posted on 2009-05-09
This worked until a few days ago on my test system, I don't know what circumstances changed but what am I doing wrong please?
I have two databases on my sql server. One is the master database and holds a single row (with 25 columns) per item stored. I have a duplicate table on a separate database on the same server that I use like an archive.
In my code behind, I set up two datacontexts, one pointing to the master database table and one (that uses a different connection string on creation) that points to the archive database table. This all works fine and both datacontexts are available and working.
I then read a single row from masterdatacontext into an entity called, say, "masterRec" and then try and do an "insertonsubmit" on the archive datacontext using the whole "masterRec" I've read. I don't want to have to specify each individual column in the write as this is hideously inefficient and long-winded.
This all worked fine for a week or two, but today it doesn't work. There is an exception about trying to attach an invalid datacontext or something?
All I want to do is read from one datacontext and write the whole row in one go to the archive datacontext. That's not too much to ask is it?