Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 4.1 尝试先使用EF4.1代码创建数据库时出现奇怪错误_Entity Framework 4.1 - Fatal编程技术网

Entity framework 4.1 尝试先使用EF4.1代码创建数据库时出现奇怪错误

Entity framework 4.1 尝试先使用EF4.1代码创建数据库时出现奇怪错误,entity-framework-4.1,Entity Framework 4.1,我首先使用EF4.1和代码来创建数据库 我的mvc3模型是这样的 public class BusinessContactDetailsModel { public int Id { get; set; } [Display(Name = "Contact Date")] public DateTime ContactDate { get; set; } [Range(1, 5)] [Displa

我首先使用EF4.1和代码来创建数据库

我的mvc3模型是这样的

    public class BusinessContactDetailsModel
    {
        public int Id { get; set; }

        [Display(Name = "Contact Date")]
        public DateTime ContactDate { get; set; }

        [Range(1, 5)]
        [Display(Name = "Outcome Rating")]
        public int OutcomeRating { get; set; }

        [DataType(DataType.MultilineText)]
        public string Comment { get; set; }


        public int BusinessId { get; set; }

        [Display(Name = "Method of Contact")]
        public int FormOfContactId { get; set; }

        [Display(Name = "Follow up Date")]
        public DateTime FollowUpDate { get; set; }

    }
在构建过程中尝试运行应用程序时失败。我知道是FollowUpProperty导致了这个问题,因为它是我刚刚添加的一个新属性,奇怪的是,如果我将属性从DateTime更改为Int,它工作正常

还有其他人有过这样的问题吗

我的堆栈跟踪看起来像

[SqlCeException(0x80004005):转换为datetime时发生溢出。] System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)+125 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr&pCursor、Boolean&isBaseTableCursor)+631 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(命令行为、字符串方法、结果选项)+509 System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()+46 System.Data.SqlServerCe.SqlCeMultiCommand.ExecuteReader(CommandBehavior)+152 System.Data.SqlServerCe.SqlCeMultiCommand.ExecuteDbDataReader(CommandBehavior)+36 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior)+10 System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator转换器、EntityConnection连接、Dictionary
2标识值、List
1生成值)+8118684 System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager、IEntityAdapter适配器)+267

[UpdateException:更新条目时出错。有关详细信息,请参阅内部异常。] System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager,IENTITY适配器)+389 System.Data.EntityClient.EntityAdapter.Update(EntitySystemManager entityCache)+163 System.Data.Objects.ObjectContext.SaveChanges(SaveOptions)+609 System.Data.Entity.Internal.InternalContext.SaveChanges()+326

[DbUpdateException:更新条目时出错。有关详细信息,请参阅内部异常。] System.Data.Entity.Internal.InternalContext.SaveChanges()+372 System.Data.Entity.Internal.LazyInternalContext.SaveChanges()+48 System.Data.Entity.DbContext.SaveChanges()+47 System.Data.Entity.DropCreateDatabaseIfModelChanges
1.InitializeDatabase(TContext上下文)+502
System.Data.Entity.c_uuuDisplayClass2
1.b_0(DbContext c)+143 System.Data.Entity.Internal.c_DisplayClass5.b_3()+59 System.Data.Entity.Internal.InternalContext.PerforminizationAction(Action Action)+101

[DataException:初始化数据库时发生异常。有关详细信息,请参阅InnerException。] System.Data.Entity.Internal.InternalContext.PerforminizationAction(Action Action)+157 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()+260 System.Data.Entity.Internal.LazyInternalContext.b_u4(InternalContext c)+31 System.Data.Entity.Internal.RetryAction
1.PerformAction(TInput输入)+147
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1 Action)+276 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()+112 System.Data.Entity.Internal.InternalContext.Initialize()+41 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)+34 System.Data.Entity.Internal.Linq.InternalSet
1.Initialize()+148
System.Data.Entity.Internal.Linq.InternalSet
1.GetEnumerator()+33 System.Data.Entity.Infrastructure.DbQuery
1.System.Collections.Generic.IEnumerable.GetEnumerator()+91
System.Collections.Generic.List
1..ctor(IEnumerable
1 collection)+315
System.Linq.Enumerable.ToList(IEnumerable
1源代码)+58 C:\Users\sp\documents\visualstudio 2010\Projects\MyApplication.CRM\MyApplication.CRM\Controllers\BusinessController.Index()中的MyApplication.CRM.Controllers.BusinessController.Index() lambda_方法(闭包、控制器基、对象[])+96 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,对象[]参数)+17 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext ControllerContext,IDictionary
2参数)+208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary
2个参数)+27 System.Web.Mvc.c_DisplayClass15.b_12()+55 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter筛选器、ActionExecutingContext预文本、Func
1 continuation)+263
System.Web.Mvc.c__显示类17.b__14()+19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext ControllerContext,IList
1过滤器,ActionDescriptor ActionDescriptor,IDictionary
2参数)+191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext ControllerContext,String actionName)+343
System.Web.Mvc.Controller.ExecuteCore()+116
System.Web.Mvc.ControllerBase.Execute(RequestContext-RequestContext)+97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext RequestContext)+10
System.Web.Mvc.c__显示类b.b__5()+37
System.Web.Mvc.Async.c__显示类1.b__0()+21
System.Web.Mvc.Async.c_uuudisplayClass8
1.b_uuu7(IAsyncResult)+12 System.Web.Mvc.Async.WrappedAsyncResult`1.End()+62 System.Web.Mvc.c_DisplayClasse.b_d()+50 System.Web.Mvc.SecurityUtil.b_0(操作f)+7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(操作)+22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+60 System.Web.Mvc.MvcHandler.System.Web.IHTTPassynchandler.EndProcessRequest(IAsyncResult结果)+9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+8862381 系统