Extending CodeFirst (EntityFramework) to Multiple Levels of 1 to 1 Relationships (Strongly Typed)

In my previous post, I showed how to take a simple relationship between Customers and an one Detail per customer build that into a relationship that eagerly loaded the customer record when retrieving a Detail record with CodeFirst in EntityFramework.  Now, let’s extend that so that a customer has an Address associated with them. This means, the relationship is as follows: Detail     Customer         Address Or, using my favorite Sql Manager Tool http://www.sqlmanager.net/ from EMS Database Management Solutions:     The model is now as follows: namespace Con1 { public class SiteDB : DbContext { public DbSet<Detail> Details { get; set; } … Continue Reading

Working With Nested Class In Simple 1 to 1 Relationship with EntityFramework 4 CodeFirst

Surprisingly, (and happily) it’s not hard to reference all data inside a class using EF’s codefirst in a 1 to 1 type relationship.  Let’s take as an example a very simple relationship where we have a customer who has a detail record.  The model definition for this is as follows: namespace Con1 { public class SiteDB : DbContext { public DbSet<Detail> Details { get; set; } public DbSet<Customer> Customers { get; set; } } public class Customer { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } public string Name { get; set; } } public class Detail { [Key] … Continue Reading

Getting ExtJS 4 Date Format To Behave Properly in Grid Panel with ASP.NET MVC3

  Introduction and Problem Converting Data Formats back and forth between browser and back end servers can be a little confusing.  In my case, I have a simple Sencha ExtJS 4.0 form that the user types a date into.  That date gets passed through an ajax request to the Microsoft asp.net controller, then that dates updates the SqlServer Database.  When the Date is displayed on a Grid Panel, again, an ajax request is made that grabs the date from the controller, then formats it using the MS dateFormat from ExtJS and hopefully, the same date the user typed in gets re-displayed. If you have a problem like this involving ASP.NET or Sencha Tools (ExtJS, SenchaTouch), more information about our consulting … Continue Reading

How to Automate a Simple Deploy Using DataDude (Visual Studio 2008 Database Edition)

Not sure why this was hard, but I wanted to make a trivial command file to deploy my database (or any change to it).  For those of you that don’t know the DataDude project, I have to say it’s one of the coolest tools that has come out the Microsoft Visual Studio Team for a while.  Basically, in a nutshell, what it does is split’s your database into hundreds of little files.  One for each table, key, foreign key, user, role, etc.  Then, since it is a standard VS2008 project, you can keep those files and the project under source control.  The big benefit is that multiple team members can change files and check them in, and everyone’s schema is kept up to date. … Continue Reading


Get every new post delivered to your Inbox

Join other followers: