Tag Archives: MVC

Project: Corsi Database – Initial Database Seed and Grid Display

Seeding the database with test data

With the initial database model defined, I created a seed method to load some sandbox data – this seed method is referenced in the system start-up and will create and populate the database if there is nothing present:

Corsi Database Initialization

Corsi Database Initialization at System Start

Corsi Database Seed Method

Corsi Database Seed Method (called if the database does not exist)

Of course, this whole seeding process is just to kick-off the project, so that we have a sandbox of information to test and view. In the future, we’ll add game data every night as it becomes available.

Getting to a View of the Data

We are using the Model-View-Controller (MVC) pattern. The Model is coming together nicely now that we have data in the database. We need to create the Controller and View to allow us to navigate and display the data.

I ran into a bit of a snag when I couldn’t get Visual Studio to auto-generate this for me because I was using MVC 4 with Entity Framework 6, so after figuring out how to upgrade, I was able to get Visual Studio to build out the scaffolding for me. I had to use the Nuget Package Manager’s Update section to bring in the necessary MVC 5.x upgrade package.

I then used Nuget to install Grid.MVC to start making the data look pretty. I needed to bring in Bootstrap and JQuery to round out the formatting.

I added a logo and voila, we have our first web browser accessible view of the base data that we’ll use to compute Corsi stats.

Initial MVC GameEvents View

Initial MVC GameEvents View

Advertisements

Project: Corsi Database – Moving to ASP.NET MVC

With the eventual plans to allow a browser accessible interface to Corsi data, I’ve started the migration of the previous WinForm application to a ASP.NET web application, built using the MVC framework. To do this, I’ll be using Visual Studio Express 2013 for Web development, Entity Framework for data management and SQL Sever Express Edition 2014 as the database host. Once I get this working on machine, this should provide a low-resistance path to move to Azure hosting.

After creating the basic MVC project, I’ve used the Nuget Manager, to add in the smarts for the Entity Framework – this will create an interface to the SQL database that I can work with in code.

Entity Framework

Entity Framework

My database will change, but just to get started, I’ve used the Model First approach to rig up the very basic database.

MVC Model First

MVC Model First

With this in place, our next steps is to seed the data and show the basic information using a MVC View Controller.