我有2个项目。第一个项目是一个dll项目,第二个是一个mvc4网站。在 dll 中,我有一个实体数据模型,我自动生成了 DbContext。
在 Global.asax 我用这一行初始化数据库:
System.Data.Entity.Database.SetInitializer( new DropCreateDatabaseAlways<WebConfigEntities>() );
当我启动网站时,我得到一个 TypeLoadException
Server Error in '/' Application.
GenericArguments[0], WebConfigDB.WebConfigEntities, voor System.Data.Entity.IDatabaseInitializer`1[TContext] is in strijd met de beperking van typeparameter TContext.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: GenericArguments[0], WebConfigDB.WebConfigEntities, voor System.Data.Entity.IDatabaseInitializer`1[TContext] is in strijd met de beperking van typeparameter TContext.
Source Error:
Line 46:
Line 47: BundleTable.Bundles.EnableDefaultBundles();
Line 48: }
Line 49: }
Line 50: }
Source File: D:\projecten\MD2400\WebConfig\Global.asax.cs Line: 48
Stack Trace:
[TypeLoadException: GenericArguments[0], WebConfigDB.WebConfigEntities, voor System.Data.Entity.IDatabaseInitializer`1[TContext] is in strijd met de beperking van typeparameter TContext.]
WebConfig.MvcApplication.Application_Start() in D:\projecten\MD2400\WebConfig\Global.asax.cs:48
我怎么解决这个问题?