简单的项目,新鲜的 MVC4 剃须刀网页,新的空 mysql 数据库。得到这个例外:
System.Reflection.TargetInvocationException was unhandled by user code
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Threading.LazyInitializer.LazyHelpers`1.ActivatorFactorySelector()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at System.Threading.LazyInitializer.EnsureInitialized[T](T& target, Boolean& initialized, Object& syncLock)
at KHSWebsite.Filters.InitializeSimpleMembershipAttribute.OnActionExecuting(ActionExecutingContext filterContext) in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 21
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func`1 nextInChain)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<>c__DisplayClass3b.<BeginInvokeActionMethodWithFilters>b__35()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func`1 nextInChain)
InnerException: System.InvalidOperationException
Message=The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588
Source=KHSWebsite
StackTrace:
at KHSWebsite.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 45
InnerException: System.InvalidOperationException
Message=The connection string 'DefaultConnection' in the application's configuration file does not contain the required providerName attribute."
Source=EntityFramework
StackTrace:
at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()
at System.Data.Entity.Database.Exists()
at KHSWebsite.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 34
InnerException:
这是我的 web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=KHS;Integrated Security=SSPI;"/>
</connectionStrings>
<system.web>
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DefaultConnection" applicationName="KHS" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed"/>
</providers>
</membership>
<compilation debug="true"/>
</system.web>
</configuration>
这已从http://msdn.microsoft.com/en-us/library/6e9y4s5t(v=vs.100).aspx获取和修改
有什么想法吗?谢谢