System.Data.Entity.Core.EntityCommandExecutionException SqlException: Invalid column name

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; }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值