views:

15

answers:

1

i have two sql servers, with same database, now i want copy some data from one to second. i added to project two linq to sql classes, and now, when i write query i have error because of name collision, how can i avoid it???

+2  A: 

If the schema is the same (like it sounds), you should be able to use the same model, but just use different connection-strings / connections to initialize two data-context instances. The problem however, is likely to be detaching objects from one model to pass to the other, and all the primary key goodness. In essence, I would recommend copying the objects and passing different objects with different keys to the second model.

Also, if the volume is very high, you might find SqlBulkCopy coupled to SqlDataReader useful; but that doesn't use LINQ-to-SQL at all.

Marc Gravell
+1 for alternate suggestion that sounds like it may be a better solution
Andrew Barber