Geeks With Blogs
Ken sent me about .net and such

Before any coding we first make sure that the project is setup correctly. (Please note, that this blog is all about how I do it, and incase i forget, i can return here and read how i used to do it. Maybe you come up with some idea’s for yourself too.)

In these series we will create a minigolf scoring cart. Please note that we eventually create a fully functional application which you cannot use unless you pay me alot of money! (And i mean alot!)

 

1. Download and install the appropriate tools.

Download the following:

- TestDriven.Net (free version on the bottom of the download page)

- nUnit

TestDriven is a visual studio plugin for many unittest frameworks, which allows you to run  / test code very easily with a right click –> run test. nUnit is the test framework of choice, it works seamless with TestDriven.

 

2. Create your project

Fire up visual studio and create your DataAccess project:  MidgetWidget.DataAccess is it’s name. (I choose MidgetWidget as name for the solution). Also, make sure that the MidgetWidget.DataAccess project is a c# ClassLibary

image

Hit OK to create the solution. (in the above example the checkbox Create directory for solution is checked, because i’m pointing the location to the root of c:\development where i want MidgetWidget to be created.

 

3. Setup the database.

You should have thought about a database when you reach this point. Let’s assume that you’ve created a database as followed:

Table name: LoginKey
Fields: Id (PK), KeyName (uniqueidentifier), StartDate (datetime), EndDate (datetime)

Table name:  Party
Fields: Id (PK), Key (uniqueidentifier, Created (datetime)

Table name:  Person
Fields: Id(PK),  PartyId (int), Name (varchar)

Tablename: Score
Fields: Id (PK), Trackid (int), PersonId (int), Strokes (int)

Tablename: Track
Fields: Id (PK), Name (varchar)

A few things to take note about the database setup. I’ve singularized all tablenames (not “Persons“ but “Person”. This is because in a few minutes, when this is in our code, we refer to the database objects as single rows. We retrieve a single Person not a single “Persons” from the database.

 

4. Create the entity framework

In your solution tree create a new folder and call it “DataModel”. Inside this folder: Add new item –> and choose ADO.NET Entity Data Model.

Name it “Entities.edmx” and hit  “Add”.

Once the edmx is added, open it (double click) and right click the white area and choose “Update model from database…". Now, point it to your database (i include sensitive data in the connectionstring) and select all the tables. After that hit “Finish” and let the entity framework do it’s code generation. Et Voila, after a few seconds you have set up your entity model.

image

Next post we will start building the data-access! I’m off to the beach.

Posted on Sunday, May 27, 2012 12:27 PM | Back to top


Comments on this post: Setting up your project

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © ssoolsma | Powered by: GeeksWithBlogs.net