EF6实体核心映射问题

时间:2016-09-29 14:31:12

标签: c# entity-framework c#-4.0 entity-framework-6

我在我的一个项目中使用EF 6.1.3,最近我遇到了一个有趣的错误。当我在选择查询中使用下面的Investigation类时,它会抛出下面附带的错误。

一旦我替换服务器上的Entity Framework特定dll,错误就会得到解决。但我不能做这个制作。任何人都可以帮助我理解有关此错误的任何信息,看看如何解决它?

表定义:

    CREATE TABLE [dbo].[Investigation](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [StatusId] [int] NOT NULL,
    [CreatedOn] [datetime2](7) NOT NULL CONSTRAINT [DF_Investigation_CreatedOn]  DEFAULT (getdate()),
    [AssignedOn] [datetime2](7) NULL,
    [DueBy] [datetime2](7) NULL,
    [LastModified] [datetime2](7) NOT NULL,
    [LastModifiedBy] [uniqueidentifier] NOT NULL,
    [IsSent] [bit] NOT NULL,
 CONSTRAINT [PK_Investigation] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

Model类是

public partial class Investigation
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public Investigation()
        {
            InvestigationHistories = new HashSet<InvestigationHistory>();
            Investigators = new HashSet<Investigator>();
            SubTopicInvestigationAssocs = new HashSet<SubTopicInvestigationAssoc>();
        }

        public int Id { get; set; }

        public int StatusId { get; set; }

        [Column(TypeName = "datetime2")]
        public DateTime CreatedOn { get; set; }

        [Column(TypeName = "datetime2")]
        public DateTime? AssignedOn { get; set; }

        [Column(TypeName = "datetime2")]
        public DateTime? DueBy { get; set; }

        [Column(TypeName = "datetime2")]
        public DateTime LastModified { get; set; }

        public Guid LastModifiedBy { get; set; }

        public bool IsSent { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<InvestigationHistory> InvestigationHistories { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<Investigator> Investigators { get; set; }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<SubTopicInvestigationAssoc> SubTopicInvestigationAssocs { get; set; }
    }

错误。

  

错误:System.Data.Entity.Core.EntityCommandCompilationException:准备命令定义时发生错误。有关详细信息,请参阅内部异常---&GT; System.Data.Entity.Core.MappingException:为EntitySet生成的查询视图&#39;调查&#39;无效。查询解析器抛出以下错误:参数类型&#39; Edm.DateTime&#39;与该物业不兼容&#39; LastModifiedBy&#39;正式的#Edm.Guid&#39;。近成员访问表达式, 第3行,第112列..          在System.Data.Entity.Core.Mapping.ViewGeneration.GeneratedView.GetCommandTree()          在System.Data.Entity.Core.Mapping.ViewGeneration.GeneratedView.GetInternalTree(命令targetIqtCommand)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.ExpandView(ScanTableOp scanTableOp,IsOfOp&amp; typeFilter)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.ProcessScanTable(Node scanTableNode,ScanTableOp scanTableOp,IsOfOp&amp; typeFilter)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Visit(ScanTableOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.ProcessJoinOp(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.VisitJoinOp(JoinBaseOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Visit(ProjectOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Visit(FilterOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Visit(ProjectOp op,Node n)          在System.Data.Entity.Core.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)          在System.Data.Entity.Core.Query.InternalTrees.BasicOpVisitorOfNode.VisitDefault(Node n)          在System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Process(Dictionary 2& tvfResultKeys) at System.Data.Entity.Core.Query.PlanCompiler.PreProcessor.Process(PlanCompiler planCompilerState, StructuredTypeInfo& typeInfo, Dictionary 2&amp; tvfResultKeys)          在System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Compile(List 1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set 1&amp; entitySets)          在System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory,DbCommandTree commandTree,DbInterceptionContext interceptionContext,IDbDependencyResolver resolver,BridgeDataReaderFactory bridgeDataReaderFactory,ColumnMapFactory columnMapFactory)          ---内部异常堆栈跟踪结束---          在System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory,DbCommandTree commandTree,DbInterceptionContext interceptionContext,IDbDependencyResolver resolver,BridgeDataReaderFactory bridgeDataReaderFactory,ColumnMapFactory columnMapFactory)          在System.Data.Entity.Core.EntityClient.Internal.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest,DbCommandTree commandTree,DbInterceptionContext interceptionContext)          在System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.CreateCommandDefinition(ObjectContext context,DbQueryCommandTree tree)          在System.Data.Entity.Core.Objects.Internal.Object

0 个答案:

没有答案