Database Reference
In-Depth Information
Supporting frameworks for persistence
To familiarize you with SQL ORM's in Visual Studio, it would be negligent if I did not
cover Entity Framework, XML serialization, and C# reflection as not only NSB, but many
frameworks are based on these techniques. When working with SQL Server, it is not un-
common to have several Entity Framework tools for administration, monitoring, and
synching data in SQL Server; otherwise, the alternative would likely be SQL scripting and
stored procedures.
NServiceBus, as well as any ESB, is heavily reliant on XML serialization and object reflec-
tion, which will be covered as well.
In this section, we will be using the
PayQueue
solution:
•
MyMessages
: This is a payment message used for the projects
•
AppForWritingXML
: This is a project that writes payment XML files to a local
C:\
drive
•
AppForReadingXML
: This is a project to read XML files from the drive, which
saves a copy to the local database through Entity Framework, using the routines
from the
AppForWritingToTable
routines and sending them to MSMQ to
process as messages
•
AppForWritinTables
: These are just the data access routines for
Ap-
pForReadingXML
The
AppForWritingXML
creates 5 XML files into
C:\Load_XML_Files
. The
Ap-
pForReadingXML
will load the XML messages into the
Payment
table. The
Payment
table for sending payments, the
AppForReadingXML
table for receiving payments, the
unicastconfig
table and
auditconfig
tables need to be created. We see that the
messages move from files to the
Payment
table to the
AppForReadinXML
table using
various coding methods. A
PayQueue
database must be created in the
SQLExpress
. If
the database is new and the tables need to be created, then run the
Model.edmx
to create
the tables from the
Model.edmx
file of
AppForWritingForTables
using the "Gen-
erate Database from model". This will create a file called
Model1.edmx.sql
that when
run will create the tables. This SQL script can be run to create the tables from Visual Studio
2012. These were ran in VS2012 in Windows Server 2012, with MSMQ, DTC, NSer-
viceBus references, and SQL Server 2012 Express LocalDB installed. Ensure that DTC,
MSMQ, and NServiceBus is set up per
http://docs.particular.net/nservicebus/preparing-