Tuesday, April 17, 2012

MVC 4 / Firebird / EF 4.1 and Database First

My first blog and it's about giving back to the community I've received so much from.
Recently decided to concentrate my efforts on MVC4, Entity Framwork 4.1 and Firebird after spending a year trying to master Silverlight with MVVM. A recent post on Single Page Application Overview By Brad Severtson led me to his great presentation given by Steve Sanderson (http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159). As I'm more interested in Database First development and given that code first is the preferred method shown in examples, I decided to try and convert the beta example with Firebird and Database First. The results of my journey are below. Products used: Microsoft MVC4 Beta with the latest SPA templates, Firebird 2.5 and Firebird 2.7.5 asp dotnet drivers.
Preexisting Firebird database used in my examples.
Metadata view
Data View

Start of new MVC 4 app / Name=SPA1

Template selection

Nuget update for SPA template

Restart solution
Delete automatically created todoitem page not begin used or create todo table in database.
Add the Model

Make sure you arUsing EF 4.1 and Select ADO.NET Entity Data Model

I uesd an established connection fromVS2010
Use SPA1Context for all naming
Select a few Tables. Products used in test

Make all keys Identity type
Code generation item to make a simple DB Context.
Select ADO.Net DbContext
A review of model

This is what got created.

Must do a build before using Controllers
Add new Controller
Select options for dropdowns

Important to select SPA1ContextEntities

Generated javascript
Generated c#
Generated View

Web Config

Product Index

Add Product to Main Menu in _Layout.cshtml

Default page When testing new website

Products Page

Edit to change a product. No postbacks occur.

A view of changed products before saving. All modified rows are hi-lighted

View after pressing save button

View of data stored in table
The End.


  1. Hi,
    Very interesting but the audience should be larger if you don't use a commercial product like Devart Entity Model in the sample.

    Thanks a lot,
    A new bee

  2. I didn't use devart, I just tried product and seem to remember that it didn't work with FB. At any rate I will fix the slide as I see both ADO and devart are hi-lighted. This uses ADO.Net Entity Data Model.

  3. LLBLGen Pro works pretty well with FB.

  4. Thank you for the great example. I was having a really hard time finding a good database first example for use with a Single Page application. I really appreciate your efforts because you helped to get me started.

  5. Hi John, great post, I shared it to a LinkedIn group http://lnkd.in/6u9RtK

  6. Thank goodness for a DBFirst example. Thank you very much for going through the trouble!

  7. Hello John ... I'm starting in Asp.Net MVC 5 and need to use the database firebird however I can not use it with entity framework! ..

    Could you provide me the source of this example for studies?

    Thank you so much,