System.Data.Entity.Core.EntityCommandExecutionException
HResult=0x8013193C
Message=An error occurred while executing the command definition. See the inner exception for details.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__1()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TelerikWpfApp1.Services.TestContentProvider.Load() in C:\work\xnext\ODTCockpit\TelerikWpfApp1\Services\TestContentProvider.cs:line 24
at TelerikWpfApp1.ViewModels.TestContentEditorViewModel.LoadProjects() in C:\work\xnext\ODTCockpit\TelerikWpfApp1\ViewModels\TestContentEditorViewModel.cs:line 46
at TelerikWpfApp1.ViewModels.TestContentEditorViewModel..ctor(ITestContentProvider testContentProvider) in C:\work\xnext\ODTCockpit\TelerikWpfApp1\ViewModels\TestContentEditorViewModel.cs:line 41
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
SqlException: Invalid column name 'TestProject_Id'.
怎么解决
在这个表上的导航属性上加ForeignKey
[ForeignKey("ProjectId")]
public virtual TestProject TestProject { get; set; }