CQRS Question - I want to use MongoDB for my reads/queries and MSSQL for my data writes


#1

Should I have a separate event handler for when I want to write data to my MSSQL?, or can it go in with the same handler that writes the data to MongoDB?


#2

You can use the same event handler, as with mongodb.
Bad Practice:
Use the dbcontext in your event handler and write data to the mssql database from handler.

Best Practice:
Use the repository pattern to call your db context from there.

You have to write to both DBs in order for your reads to work from MongoDB, so that can cause some problems.