You're going to want to creat objects and insert them into MongoDB
collections via the C# driver, and the easiest way to do that in SSIS
would be through a Script Component:
http://msdn.microsoft.com/en-us/library/ms136118.aspx
The tricky part about this is that quite often you will want to
combine data from several tables into a single document in MongoDB,
but I'll try to walk through some of the scenarios herein.
Add a script component to your SSIS project, and in that component,
override the ProcessInputRows method as demonstrated here:
http://msdn.microsoft.com/en-us/library/ms187303.aspx
For each row (each call from SSIS to ProcessInputRows), you'll want to
insert a document into some MongoDB collection, so create a class with
properties for all the fields in the row and handles MongoDB specifics
(like the id field). Then use
MongoServer.Create(connectionString).GetDatabase(dbName).GetCollection<T>(collectionName).Save(obj)
for each row input you're processing. Make sure to include the PK
field from the row in the SQL DB if you've got other tables that
you'll be importing that need to reference it.
Of course, in doing this, you'll end up with flat collections, just
like MSSQL tables, and I think you'll prefer to have the complex
structure provided by documents for including subproperies within your
documents. For example, in SQL Server, you might have a table of
people and have another table where you store each person's list of
phone numbers. In MongoDB, you probably want to store the phone
numbers in the same document as the person, rather than a separate
table as you might in SQL Server.
To get this, at later steps in your data flow after importing the
people, you will want to add additional script components that look up
the document for each person and set a field (e.g. PhoneNumbers) in
that document to an array, pushing a new phone number for each phone
number coming from the MSSQL source. To do so, you'll do something
like this in the ProcessInputRows for each row of people's phone
numbers (using a people collection):
people.Update(Query.EQ("PersonID", personId),
Update.Push("PhoneNumbers", phoneNumber));
I recommend creating List properties on your root document objects for
any of these sub collections so when you create the initial document,
the property for the subcollection will be initialized to an empty
list. For example, when you save the initial Person object, make sure
it has a propery Person.PhoneNumbers that is initialized to an empty
List. Then you won't have to worry with creating the PhoneNumbers
field in the document as you are processing each phone number...you
can safely call Push.
I hope that helps. If you run into issues, feel free to post relevant
parts of your code and stack trace.
-Dave