Tag Archives: technology

Opening SQL Server Compact Files

Today I am taking a look at some code someone else developed.  They used SQL Server Compact database files (.sdf), which I have read about but never personally used.  I went on a little journey to simply open the file and see what is inside.

Of course, my first assumption was, “Use SQL Server Management Studio.”  Alas, the file would not open in neither SSMS 2008R2 nor SSMS 2010.  After Googling for a little bit, I realized Visual Studio was the place to go.  All I needed to do was install the SQL Server Compact Toolbox:

  • Open Visual Studio 2010
  • Click Tools >> Extension Manager
  • Click Online Gallery and search for “SQL Server Compact”
  • Click “SQL Server Compact Toolbox” and Download
Then, to open the .sdf file, I had to
  • Go to the Server Explorer section
  • Add a new connection
  • Change the data source to Microsoft SQL Server Compact X.X (in my case 3.5 worked)
  • Find the database using “Browse” and test the connection
And there it was!  Now I can explore the data tables as I expected to.  Now to see how this program works…

Unit Testing while using Entity Framework

I have been recommended to use Entity Framework (EF) instead of LINQ to SQL while building .NET applications. So I pulled out some reference materials, learned the beginning concepts of EF, and started to build an application.

Then I started trying to figure out how to do Unit Testing and Test Driven Development (TDD) while using EF.  What I had read about EF showed me how to build a SQL Server database and then have Visual Studio build the entities for me. I had to design the entire database first and then leave all the classes tied to the database, both of which are incompatible with TDD and Unit Testing.

So I started my Google search, and these are the documents I found really helpful. In the end, Unit Testing and TDD are compatible with EF!  Here is where my journey took me:

TDD and ADO.NET Entity Framework
This late 2008 posting has several people sharing their concerns about using TDD with EF, which is where I was yesterday morning.

Walkthrough: POCO Template for the Entity Framework
Feature CTP Walkthrough: POCO Templates for the Entity Framework
These articles shows how to use the  ADO.NET C# POCO Entity Generator and the Microsoft ADO.NET Entity Framework Feature Community Technology Preview 3 assembly to separate a .edmx Entity Framework file into two groups of classes: the persistence ignorant entity classes (not connected to the database), and the data context class which talks with the database.

Feature CTP Walkthrough: Code Only for the Entity Framework (Updated)

This posting illustrates how to build an EF from code only, without using Visual Studio’s automated generators.  In this process, they were able to keep the persistence ignorant entity classes separate from the database context classes.  This technique required the Microsoft ADO.NET Entity Framework Feature Community Technology Preview 3 assembly.
These articles illustrate how to practically use TDD and EF together!
Now I feel prepared to move forward using Entity Framework together with Test Driven Development methodologies!

Technologies Overview

Here I will describe some of the technologies I have been studying for the last couple years. Of course, this list is not exhaustive by any means.

I will start with the basics here, and hopefully write about some of the programming and database technologies I use soon.

Basic Website Technologies

HTML (Hypertext Markup Language)/XHTML (Extensible Hypertext Markup Language)
The main infrastructure of web technology is HTML. When I started building websites, I was amazed to find out that so much can be done in Notepad or any other text-editor! You can write all the HTML in a text document, change the file extension to .htm or .html and then open the file in a browser. It works!

There are plenty of WSYWIG (What You See Is What You Get) editors out there. I personally like to write my own HTML code rather than use WSYSWIG so that I have full control over the website design. When my website does not work in a certain browser, I have the control to tinker and eliminate problems. Also, when something does not work, I can take full responsibility rather than blame a piece of software because I trusted it to do what I wanted.

For the best place to get started learning HTML (as well as several other technologies), I highly recommend w3schools.com. They do a great job setting a solid foundation from which to build, and they have several resources and when you need to find out what a tag does, or what your options are.

As good practice, I used HTML strictly to set the structure of my website and add content. Separating presentation and content is very helpful as I will explain with CSS below.

CSS (Cascading Style Sheets)
Before CSS was created, all aspects of presentation (fonts, colors, sizes, alignments, and other formatting) were listed inside the HTML tags using attributes. When building a themed website, each page would have to be created in a similar way. If the background color were to be changed from red to blue, this would mean every single page would individually need to be edited.

CSS is glorious! Now HTML can be used to contain mostly the HTML tags and the content of the web pages. A single CSS file can contain all the formatting necessary for an entire website and each HTML page simply needs to have a link to the CSS file.

Alternatively, several style sheets may be used for a website. I like to have one style sheet describe positioning, sizes, and fonts and I have other style sheet describe different color schemes. This allows me to easily change “themes” for different parts of a website while maintaining a consistent infrastructure. As another option, different style sheets can be used for different types of browsers, such as a desktop/laptop, a mobile browser, or a printer.

Browsers
There are several browsers out there. The main ones I have installed on my machine are Chrome, FireFox (FF), Internet Explorer (IE), Opera, and Safari. I love using the Google Chrome. It is simple and fast, which I really enjoy.

I started using Opera a little when dinking around. I really like how fast and smooth it works. I was really impressed with my first impressions. Since I was already using Chrome, I did not see a strong advantage to switching, but I would have if I had not met Chrome first.

FireFox is pretty neat. FF is definitely better than IE. Their FireBug plugin is a definite must-have for any web designer or developer. FireBug lets you look at the different elements of the rendered webpage and see what tags and styling were used. This tool has helped me in many, many instances where I could not figure out why parts of my site looked the way they did.

Internet Explorer is burly and sluggish. I tend to only use it when I need to access SharePoint or other sites that were built to work with IE. Also I use it just to see what 40-50% of the people out there will see since IE is still pretty popular.

I have not worked with Safari much.

Resources
• www.w3schools.com

Next Time…
Later I hope to do some summaries of the more advanced technologies I have been using, such as client-side and server-side programming languages and databases, which I really enjoy working with.