title: Using EF data migrations having a seed issue
body: <p>I am using data migrations and in my seed method I am trying to seed a Class entry for a educational app.  I have successfully seeded my teachers objects, and now I am trying to see my Classes object.  I want to match upon teacher and class name, and add or update as necessary.  However, when doing a database-update I am getting an error with the following line of code. </p>
  
  <pre><code>context.Classes.AddOrUpdate(c =&gt; new { c.Teacher, c.Name },
     new Class { Teacher = context.Teachers.Where(t =&gt; t.LastName == "Smith").First(), Name = "2nd Grade" }
  );
  </code></pre>
  
  <p>Error Message:</p>
  
  <pre><code>System.NotSupportedException: Unable to create a constant value of type 'System.Data.Entity.DynamicProxies.Teacher_1D51D38A8AE43965E18EC50416D4BEA3D0F01817052D6D72EAEB1EFF88235B9B'. Only primitive types or enumeration types are supported in this context.
     at System.Data.Objects.ELinq.ExpressionConverter.ConstantTranslator.TypedTranslate(ExpressionConverter parent, ConstantExpression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.EqualsTranslator.TypedTranslate(ExpressionConverter parent, BinaryExpression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.BinaryTranslator.TypedTranslate(ExpressionConverter parent, BinaryExpression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding&amp; binding)
     at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression&amp; source, DbExpressionBinding&amp; sourceBinding, DbExpression&amp; lambda)
     at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.FirstPredicateTranslatorBase.Translate(ExpressionConverter parent, MethodCallExpression call)
     at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SinglePredicateTranslatorBase.Translate(ExpressionConverter parent, MethodCallExpression call)
     at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
     at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
     at System.Data.Objects.ELinq.ExpressionConverter.Convert()
     at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
     at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
     at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator()
     at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
     at System.Data.Objects.ELinq.ObjectQueryProvider.&lt;GetElementFunction&gt;b__2[TResult](IEnumerable`1 sequence)
     at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
     at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
     at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
     at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
     at System.Data.Entity.Migrations.IDbSetExtensions.AddOrUpdate[TEntity](DbSet`1 set, IEnumerable`1 identifyingProperties, TEntity[] entities)
     at System.Data.Entity.Migrations.IDbSetExtensions.AddOrUpdate[TEntity](IDbSet`1 set, Expression`1 identifierExpression, TEntity[] entities)
     at LeafyGradeBook.Web.Migrations.Configuration.Seed(GradebookDb context) in c:\Users\LocalRyan\Documents\Visual Studio 2012\Projects\LeafyGradeBook\LeafyGradeBook.Web\Migrations\Configuration.cs:line 38
     at System.Data.Entity.Migrations.DbMigrationsConfiguration`1.OnSeed(DbContext context)
     at System.Data.Entity.Migrations.DbMigrator.SeedDatabase()
     at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase()
     at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
     at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
     at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
     at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
     at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
     at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
  Unable to create a constant value of type 'System.Data.Entity.DynamicProxies.Teacher_1D51D38A8AE43965E18EC50416D4BEA3D0F01817052D6D72EAEB1EFF88235B9B'. Only primitive types or enumeration types are supported in this context.
  </code></pre>