Posted in: MVC3

Connecting to a SQL Compact database using Entity Framwork in ASP.NET

Posted on April 3, 2013 by Michael Roma

The following shows how to setup a proper connection string and DbContext in Entity Framework in order to connect to a SQL Compact database in ASP.NET.

Here is an example configuration string in your Web.Config: Here is the code for a base DbContext that uses the above connection string:

public class BaseRepository : DbContext, IDisposable
{
    // constructor, connect to database
    public BaseRepository()
        : base(new SqlCeConnection("myDatabase"),
                 contextOwnsConnection: true) { }        
    
    // dispose
    protected override void Dispose(bool disposing)
    {
        base.Dispose(disposing);
    }   
} 

Good article for a C# Razor quick reference guide

Posted on August 14, 2012 by Michael Roma

From: http://haacked.com/

"I gave a presentation to another team at Microsoft yesterday on ASP.NET MVC and the Razor view engine and someone asked if there was a reference for the Razor syntax. It turns out, there is a pretty good guide about Razor available, but it’s focused on covering the basics of web programming using Razor and inline pages and not just the Razor syntax. So I thought it might be handy to write up a a really concise quick reference about the Razor syntax."

Article: C# Razor Syntax Quick Reference