Up Write entities Code First
DevForce 2010 Resource Center » DevForce development » Model » Code First » Write entities Code First » Installing the Code First NuGet package

Installing the Code First NuGet package

Last modified on November 07, 2013 11:32

Code First support in DevForce is provided through a NuGet package.  Here we provide information on how to install the DevForce Code First NuGet package.

 This information applies to versions 6.1.9 and above.  Prior to this version, the DevForce installer installed both PostSharp and the DevForce build targets globally on the computer.

Install the package

DevForce Code First support is distributed through NuGet.

To install the DevForce 2010 Code First NuGet package in one or more projects within a solution, right-click on the Solution or an individual project, select "Manage NuGet Packages..." and enter a search term, such as "IdeaBlade.DevForce-2010".  


If you see a Code First package from both DevForce 2010 and DevForce 2012, be sure to pick the DevForce 2010 package.  The package id is IdeaBlade.DevForce-2010.Aop.

The package installs necessary DevForce files and assemblies, as well as PostSharp and EntityFramework dependencies.  This package requires that DevForce 2010 is already installed, and can be installed to Silverlight 4, Silverlight 5, and .NET 4.0 projects.  

Both the DevForce and PostSharp packages modify the MSBuild targets for the projects they are installed to.  If you peek into the project file you'll see additional imports.  For example, a C# project might look something like this:

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

  <Import Project="..\packages\PostSharp.\tools\PostSharp.targets"
     Condition="Exists('..\packages\PostSharp.\tools\PostSharp.targets')" />

  <Import Project="..\packages\IdeaBlade.DevForce-2010.Aop.6.1.9\tools\IdeaBlade.DevForce.Common.targets"
    Condition="Exists('..\packages\IdeaBlade.DevForce-2010.Aop.6.1.9\tools\IdeaBlade.DevForce.Common.targets')" />

The PostSharp targets file ensures that your Code First entities are re-written, while the DevForce targets will fire the EntityModelMetadataDeploy task which builds the metadata file for your model.

Which projects to install to?

You should install the DevForce Code First NuGet package to the project which will hold your code first model.  If you are working in Silverlight, you should also install the package to your "linked" Silverlight project.  In general, the package should be installed to any project which will contain an *ibmmx metadata file.

You should also install the DevForce Code First NuGet package to any project defining a base class to ensure that the correct assembly references are added and PostSharp MSBuild support is enabled.  If your base class uses the ProvideEntityAspect or ProvideComplextAspect aspects, then the assembly must be "enhanced" by PostSharp and requires that the MSBuild targets in the project file are modified.  

Upgrading an existing (pre-DevForce 6.1.9) Code First project

If you have an existing Code First project created with an earlier version of DevForce (prior to 6.1.9), you'll need to do the following:

  • Delete the existing .cf marker file.  The NuGet package will re-create this file.
  • Install the DevForce Code First NuGet package to all applicable projects.

The package will not update an existing EntityFramework package, and can be used with EF versions 4.1 and above.

Keep the DevForce and Code First package version in sync

The version of the DevForce 2010 Code First NuGet package must match the version of DevForce you have installed.  After upgrading from an earlier DevForce version, always be sure to also upgrade to the corresponding version of the NuGet package.  You can easily do this using the "Manage NuGet Packages" wizard to look for updates:


Alternately, if you prefer to stay at an earlier DevForce version, you'll need to make sure that you specify the version when retrieving the NuGet package.  For example, use the Package Manager console to install the 6.1.9 package:

Install-Package IdeaBlade.DevForce-2010.Aop -version 6.1.9

Newer EntityFramework packages

The DevForce Code First NuGet package supports any version of the EntityFramework NuGet package between 4.1 and 5.x.  If you install the Code First package to a project for which EF is already installed, the Code First package will not update it.  

However, if you install the Code First package to a project which does not already contain the EntityFramework package, EntityFramework 4.1 is installed.  This occurs because the DevForce package allows a range of versions, and NuGet will install the earliest version if the package is not already present.

You can separately update the EntityFramework package to your desired version by using the Package Manager wizard or console.  

DevForce 2010 does not support EF 6.

Tags: code first
Created by DevForce on November 05, 2012 14:59

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2015 IdeaBlade