The Entity Framework team released the EF Power Tools CTP1 this week. If you use Code First, you really should check this out. First, if you are not familiar with VS extensions (or the term Power Tools), these are basically helpers that  you can add into Visual Studio to make your life easier. I wrote a post on my favorite Visual Studio Extension, the Visual Studio Productivity Power Tools that you can check out here.

Quick aside … You can install EF 4.1 using NuGet.

  1. Right click your project and select Add Library Package Reference
  2. Select Online in the left menu
  3. Type EntityFramework in the search box
  4. Click the Install button
  5. image

    The EF team’s post covers the details, but I wanted to cover 2 common scenarios this helps with:

    1. I’ve Got a Database, It’s Not Complete, But I Want to Create Starter POCO Model Classes
    2. I have a Database and I want POCO classes with EF Code First, but I am not sure  what to map, how to set the DbContext up, etc.
    3. I see this most often when a team is underway in the project. Less often do I see a DB completed 100% then create a model, or a model completed 100% then a DB for that matter. My point is that if you have a database with a decent number of tables in it, you may want a quick and easy way to generate your model classes to get you going. The EF Power Tools can do this for you by pointing them to a database. At that point they will:

      • generate the model classes
      • map them using the fluent APIs
      • create the DbContext
      • add the config file settings for the database connection string (which you can then move where you need it)
      • It is a starting point, meaning that these classes can then be manually changed and tweaked as you need them. Which is exactly what I want in that case. I don’t plan on keeping them tied to the database and auto-gen’d. Instead I just want the grunt work of creating all those classes and mappings done for me and in the end to have a set of POCOs.

        This is also helpful if you have not used EF Code First yet as it will show you how the classes and mappings could look, syntax wise. Here is how you create it:

        ProjectMenu

        Check out the team;s post for more details