Mono: Entity Framework – Basic Setup Guide

So you have been using Entity Framework on Visual Studio and now you would like to code in Linux using Mono and still be able to use Entity Framework. Well this post will give you some basic steps to setup your SQL server and Mono project to get a simple database going.

Setting SQL Express

Before we can go any further we need to have Microsoft SQL Server Express installed ¬†on a Windows server. For my own setup I already have a virtual machine with Windows Server 2012 running and SQL Server Express 2014 installed. It’s up to you to choose own setup, and it doesn’t have to be the same as mine.

Create Your SimpleDatabase

Now we need to create our test database on SQL Server by running the following SQL statement on your script editor of choice:



Screenshot from 2014-06-17 21:19:27

Now you should have a brand spanking new database created and ready to be populated with data. (more…)

C#: DataTable to CSV


Recently I wrote a small program to allow me to connect to a SQL database and export a selected table to a CSV file. So I needed a method that can take in a DataTable and the delimiter character to use. The returned result is a string which can be save straight to a text file.

Below is the method in my program, you may copy, modify and use it in your own program.

I use a StringBuilder class to build my lines of comma separated values and then return it as a String type. Currently the code only format string values with double quotes inserted around the value and the rest is a straight output.