10-4 Episode 15: Model-First Development with the Entity Framework 4.0

Download this episode

Download Video


In this episode of 10-4, we introduce a new tooling enhancement coming with Visual Studio 2010 and the Entity Framework 4.0: model-first development. This feature allows you to create your Entity Data Model from scratch and then generate a database from it, as opposed to reverse engineering your EDM from an existing database.

For more 10-4 episodes, be sure to visit:

Visual Studio Topic Area on Channel 9:

Visual Studio 2010 CTP VPC:

10-4! Over and out!



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • Moemeka
      okay, when can we get our hands on this?  The wait has been waaaaay too long for my AADHD to tollerate.  Feed me seymore!  Feed me now!
    • Chris​Stepaniuk
      That is great!  It's nice to see the EF become even more mature.  It would be even better if we had more control over the physical dml is generated, or if we had a choice to output complex-types to separate tables and have them linked via a foreign key to their parent.  If the customer you created had more than one physical address, say a billing and/or shipping, you'd need to modify your database to support this or you could create a second Address complex-type, but this could get very messy, not to mention confusing.

      Also, I attempted to use EF that shipped with 3.5 on a database at work and I subsequently went back to LINQ because the EF wizard "forgot" to pull two of my tables from my database.  I attempted to regenerate the model several times with no luck.   These tables were found in the generated files, but were not present to the tool, nor did visual studio recongize them.  I also recieved compiler errors when I attempted to reference them.  I am wondering if anyone else had this problem with bridging tables which facilitate many-to-many relationships.
    • stevo_
      Note that the database connection wizard was the one who created the database, not specifically the generate database wizard from the entity framework. It's likely the wizard will always just generate a script to make you do this yourself..

      Also, isn't this entity framework v2? is there anything there regarding POCO models? I know they were suposed to be adding this, I'd much rather create ignorant models with INotifyPropertyChanged and generate a conceptual from them, and generate a database schema from the conceptual model.
    • vesuvius
      POCO models are added in, check out Pablo Castro's mix video where he says this is forthcoming
    • Analise
      Very interesting! When can we play with a new ctp? The actual one is too OLD Smiley
    • Chris​Stepaniuk
      No kidding eh?  I know that is why I'm not rushing out to download it, I'd like to try it with the new interface, warts and all.
    • Moemeka
      so are you going to be releasing another CTP or a beta anytime soon?  Its about to be May and all there is out there is as far as news is the same tired old links from October.  I'd love to read some buzz about it at least.  BTW  why isnt the .NET framework ever released before the IDE?  after all they are two totally seperate entities right?  I sont mind command line compilation and notepad coding if thats what ita takes to get my hands on this technology.
    • PerfectPhase

      As long I you fix simple things like being able to do model.DeleteCustomers (c => c.Surname == "Smith") i'll be happy.
    • foreachdev

      Features that need to be there:
      -Change scripts as well as create scripts (looks like this is already there?)
      -Sized fields like Varchar need to have some way to map back field. In fact if you could constrain the field as an EF field during any save operation that would be better. I am talking zero custom code. I set String field with Length 20 in the tooling. It throws an exception on 21+ characters.

    • bertnz
      Hi folks,

      Thought I'd mention an ORM product I've been using - Mindscape LightSpeed - which has provided model first and database first support for quite some time. It has a model designer that integrates directly into VS, supports schema round tripping in both directions and heaps more. It doesn't support such a rich conceptual modelling capability as EF but I find it fits what I need. Also supports 9 database types.

      Just thought i'd make some LightSpeed-specific comparisons with posts here -

      @PerfectPhase You can write a query similar to that using LightSpeed. UnitOfWork.Remove() takes a query object that can be as complex as you wish and will delete all records that match without returning data to the client.

      @foreachdev You can configure the LightSpeed validation in the designer to not allow persistence if a field is over a given length. If an entity has a field that had 21 characters the .IsValid flag would be false and the errors collection would supply a description of the issue to present to the user if desired. Change scripts are supported in a rough manner but this is getting much tidier in the next version I hear.

      While we wait for EF 2 to pop out you could have a look at LightSpeed Express here.

    • santosh_b

      .NET Framework 3.0 was released before the VS23008 IDE. Some extensions were added to VS2005 for WCF and WF but you could always use notepad Smiley

    • Rudsen

      It's nice to see that this concept will be improved. But i think you should have a deep look at the extended data types of Microsoft Dynamics AX. That's a great thing i currently miss in Visual Studio.

    • matthargett

      can we see how to use the API-level aspects of this framework? preferrably in a test-driven fashion? this is what I really need to see to compare this against the Rails style of development. pointing and clicking all over the UI doesn't really do it for me, I'm a keyboard-oriented person.

      I really love the 10-4 videos, especially the ones that JC does. Keep up the good work!

    • LostIn​Tangent

      LINQ To SQL is getting quit a few improvements in the .NET 4 timeframe. You can see a pretty comprehensive list here: http://damieng.com/blog/2009/06/01/linq-to-sql-changes-in-net-40

      As far as the Entity Framework being the preferred option for data access moving forward, yes, that is the case.

    • LostIn​Tangent

      Thanks for the heads up bertnz. The ORM space certainly has lots of great options.

    • LostIn​Tangent

      I'll definitely be digging into the code much more moving forward. This episode was just an initial introduction to the high level changes coming. I'll make sure to provide plenty of good detail/usage examples Smiley

    • LostIn​Tangent

      Sounds like what you want it to use Dynamics as your data store/platform, and then place the Entity Framework over it so that you can program against its dynamic entities. If so, the guys over at ADX Studio (http://www.adxstudio.com/) are working on something that handles this very nicely.

    • ethx

      Hi! What happens if i want to add enumeration to my model? How's that gonna be represented in Database?

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.