Menu

问题  MVC登录错误(如果(!context.Database.Exis

Dreal1

成员
已加入
2017年4月27日
留言内容
10
编程经验
Beginner
大家好,我是Rilwan,我一直在MVC应用程序的登录页面上工作,
if(!context.Database.Exists())。
请我真的需要您的帮助,下面是错误的屏幕快照,请注意,我正在使用窗口10。谢谢。


浏览器错误消息!!!


[h = 1]“ /”应用程序中的服务器错误。[/ h]
[h=2]该系统找不到指定的文件 [/H] 描述: 当前Web请求的执行期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中起源的更多信息。

异常详细信息: System.ComponentModel.Win32Exception:系统找不到指定的文件

源错误:

第32行:使用(var context = new UsersContext())
第33行:{
第34行:if(!context.Database.Exists())
第35行:{
第36行://创建不带实体框架迁移模式的SimpleMembership数据库

源文件: c:\ Users \ Dope \ Desktop \ MVCCRMApp \ MVCCRMApp \ Filters \ InitializeSimpleMembershipAttribute.cs Line: 34

堆栈跟踪:

[Win32Exception(0x80004005):系统找不到指定的文件]

[SqlException(0x80131904):建立与SQL Server的连接时发生了与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:52-无法找到本地数据库运行时安装。验证是否正确安装了SQL Server Express并启用了本地数据库运行时功能。)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,SqlCredential凭证,对象providerInfo,字符串newPassword,SecureString newSecurePassword,布尔值redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,DbConnectionPoolHandle,Transport + AccessToken,
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,对象poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)+332
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池,DbConnection owningObject,DbConnectionOptions选项,DbConnectionPoolKey poolKey,DbConnectionOptions userOptions)+38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)+699
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)+89
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,only Boolean OneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal& connection) +426
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource`1 retry,DbConnectionOptions userOptions,DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource`1 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& connection) +191
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection externalConnection,DbConnectionFactory connectionFactory,TaskCompletionSource`1重试,DbConnectionOptions userOptions)+154
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection externalConnection,DbConnectionFactory connectionFactory,TaskCompletionSource`1重试,DbConnectionOptions userOptions)+21
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1重试)+90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重试)+217
System.Data.SqlClient.SqlConnection.Open()+96
System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection,动作1动作)+79
System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection,Action`1 act)+374
System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection连接)+231
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection连接)+26

[ProviderIncompatibleException:提供程序未返回ProviderManifestToken字符串。
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection连接)+159
System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection连接)+32

[ProviderIncompatibleException:从数据库获取提供者信息时发生错误。这可能是由于Entity Framework使用了错误的连接字符串引起的。检查内部异常以获取详细信息,并确保连接字符串正确。]
System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection连接)+192
System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection连接,DbProviderManifest&providerManifest)+39
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)+46
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)+62
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput输入)+123
System.Data.Entity.Internal.LazyInternalContext.InitializeContext()+468
System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()+17
System.Data.Entity.Database.Exists()+36
c:\ Users \ Dope \ Desktop \ MVCCRMApp \ MVCCRMApp \ Filters \ InitializeSimpleMembershipAttribute.cs:34中的MVCCRMApp.Filters.SimpleMembershipInitializer..ctor()

[InvalidOperationException: ASP.NET 简单成员资格数据库无法初始化。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkId=256588]
c:\ Users \ Dope \ Desktop \ MVCCRMApp \ MVCCRMApp \ Filters \ InitializeSimpleMembershipAttribute.cs:45中的MVCCRMApp.Filters.SimpleMembershipInitializer..ctor()

[TargetInvocationException:调用的目标已引发异常。]
System.RuntimeTypeHandle.CreateInstance(RuntimeType类型,布尔publicOnly,布尔noCheck,布尔&canBeCached,RuntimeMethodHandleInternal& ctor, Boolean&bNeedSecurityCheck)+0
System.RuntimeType.CreateInstanceSlow(布尔publicOnly,布尔skipCheckThis,布尔fillCache,StackCrawlMark& stackMark) +114
System.RuntimeType.CreateInstanceDefaultCtor(布尔publicOnly,布尔skipCheckThis,布尔fillCache,StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(类型,布尔非公共)+83
System.Activator.CreateInstance(类型类型)+11
System.Threading.LazyHelpers`1.ActivatorFactorySelector()+68
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object&syncLock,Func`1 valueFactory)+115
System.Threading.LazyInitializer.EnsureInitialized(T& target, Boolean& initialized, Object& syncLock) +106
MVCCRMApp.Filters.InitializeSimpleMembershipAttribute.OnActionExecuting(ActionExecutingContext filterContext)在c:\ Users \ Dope \ Desktop \ MVCCRMApp \ MVCCRMApp \ Filters \ InitializeSimpleMembershipAttribute.cs:21
System.Web.Mvc.Async。AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter过滤器,ActionExecutingContext preContext,Func`1 nextInChain)+69
System.Web.Mvc.Async。<>c__DisplayClass3b.<BeginInvokeActionMethodWithFilters>b__35() +22
System.Web.Mvc.Async。AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter过滤器,ActionExecutingContext preContext,Func`1 nextInChain)+492
System.Web.Mvc.Async。<>c__DisplayClass3b.<BeginInvokeActionMethodWithFilters>b__35() +22
System.Web.Mvc.Async。<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback,对象asyncState)+190
System.Web.Mvc.Async。WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
System.Web.Mvc.Async。AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters(ControllerContext controllerContext,IList`1过滤器,ActionDescriptor actionDescriptor,IDictionary`2参数,AsyncCallback回调,对象状态)+182
System.Web.Mvc.Async。<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback,对象asyncState)+445
System.Web.Mvc.Async。WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
System.Web.Mvc.Async。AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext,字符串actionName,AsyncCallback回调,对象状态)+302
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback,对象asyncState)+30
System.Web.Mvc.Async。WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback回调,对象状态)+338
System.Web.Mvc.Async。WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext,AsyncCallback回调,对象状态)+316
System.Web.Mvc.Controller.System.Web.Mvc.Async。IAsyncController.BeginExecute(RequestContext requestContext,AsyncCallback回调,对象状态)+15
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback,对象asyncState)+71
System.Web.Mvc.Async。WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext,AsyncCallback回调,对象状态)+251
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext,AsyncCallback回调,对象状态)+48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext上下文,AsyncCallback cb,对象extraData)+16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+103
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔&同步完成)+155

版本信息: Microsoft .NET Framework版本:4.0.30319; ASP.NET Version:4.6.1590.0


我的应用程序(网络配置)

<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置您的更多信息 ASP.NET 申请,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-有关Entity Framework配置的更多信息,请访问 http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="数据源=(LocalDb)\ v11.0;初始目录= aspnet-MVCCRMApp-20170513151250;集成安全性= SSPI; AttachDBFilename = | DataDirectory | \ aspnet-MVCCRMApp-20170513151250.mdf" providerName="System.Data.SqlClient" />
<add name="CRMEntities" connectionString="元数据= res://*/Models.Model1.csdl | res://*/Models.Model1.ssdl | res://*/Models.Model1.msl; provider = System.Data.SqlClient; provider连接字符串="数据源= DP;初始目录= CRM;集成安全性= True; MultipleActiveResultSets = True; App = EntityFramework"" providerName="System.Data.EntityClient" />
<add name="CRMEntities1" connectionString="元数据= res://*/Models.Model1.csdl | res://*/Models.Model1.ssdl | res://*/Models.Model1.msl; provider = System.Data.SqlClient; provider连接字符串="数据源= DP;初始目录= CRM;集成安全性= True; MultipleActiveResultSets = True; App = EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework ="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<验证validateIntegratedModeConfiguration ="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\ Framework \ v4.0.30319 \ aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32"responseBufferLimit ="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\ Framework64 \ v4.0.30319 \ aspnet_isapi.dll" preCondition="classicMode,运行时版本v4.0,bitness64"responseBufferLimit ="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="IntegratedMode,运行时版本v4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns ="缸:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity名称="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion ="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity名称="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion ="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity名称="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion ="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity名称="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion ="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity名称="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion ="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity名称="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion ="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory类型="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" />
</entityFramework>
</configuration>



 

金西尼

C#论坛主持人
工作人员
已加入
2011年4月23日
留言内容
3,548
地点
悉尼,澳大利亚
编程经验
10+
服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:52-无法找到本地数据库运行时安装。验证是否正确安装了SQL Server Express并启用了本地数据库运行时功能。)
这似乎是对该问题及其解决方法的相当清晰的描述。
 
最佳 底部