hogenwang/comcms_core

如何初始化数据库?

Closed this issue · 6 comments

你好,没看到你们这个系统的注册入口,请问如何初始化你们的这个后台数据库?

data目录下有个sql文件,到mysql管理工具执行一下即可

我导入执行以后,输入admin admin 登录还是报错误。需要联系管理员,请问是不是你们把后台锁住了?

执行到 LoginController控制器里面的第89行(“if (AdminLog.FindCount(ex, null, null, 0, 0) >= 10)”)出错,
然后抛出“执行错误!请联系管理员”

xxred commented

@robyle
请查看一下日志,日志位于输出目录log文件夹,看看实体用的连接字符串是不是你设置那个,然后驱动是否正确。最好贴一下AdminLog.FindCount(ex, null, null, 0, 0) >= 10)报错的具体信息

@xxred ,你好。日志输出如下:
#Software: COMCMS.Web
#ProcessID: 23756 x64
#AppDomain: COMCMS.Web
#FileName: C:\Program Files\dotnet\dotnet.exe
#ApplicationType: WinForm
#CPU: 8
#Date: 2018-06-25
#字段: 时间 线程ID 线程池Y网页W普通N 线程名 消息内容
#Fields: Time ThreadID IsPoolThread ThreadName Message
17:28:06.822 10 N - COMCMS.Web v1.0.0.0 Build 2000-01-01
17:28:06.824 10 N - COMCMS.Web
17:28:06.824 10 N - XCode v9.7.2018.0512 Build 2005-07-11 00:17:04
17:28:06.824 10 N - 大数据中间件 ©2002-2018 新生命开发团队 http://www.NewLifeX.com
17:28:22.696 10 N - System.ArgumentException: An item with the same key has already been added. Key: dbconn
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at XCode.DataAccessLayer.DAL.get_ConnStrs() in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 183
at XCode.DataAccessLayer.DAL..ctor(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 36
at XCode.DataAccessLayer.DAL.Create(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 72
at XCode.EntitySession1.get_Dal() in E:\X\Src\XCode\Entity\EntitySession.cs:line 118 at XCode.Entity1.FindCount(Expression where, String order, String selects, Int64 startRowIndex, Int64 maximumRows) in E:\X\Src\XCode\Entity\Entity.cs:line 816
at COMCMS.Web.Areas.AdminCP.Controllers.LoginController.Login() in D:\Projects\Github\comcms_core\COMCMS.Web\Areas\AdminCP\Controllers\LoginController.cs:line 89
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
17:29:42.111 24 N - System.ArgumentException: An item with the same key has already been added. Key: dbconn
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at XCode.DataAccessLayer.DAL.get_ConnStrs() in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 158
at XCode.DataAccessLayer.DAL..ctor(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 36
at XCode.DataAccessLayer.DAL.Create(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 72
at XCode.EntitySession1.get_Dal() in E:\X\Src\XCode\Entity\EntitySession.cs:line 118 at XCode.Entity1.FindCount(Expression where, String order, String selects, Int64 startRowIndex, Int64 maximumRows) in E:\X\Src\XCode\Entity\Entity.cs:line 816
at COMCMS.Web.Areas.AdminCP.Controllers.LoginController.Login() in D:\Projects\Github\comcms_core\COMCMS.Web\Areas\AdminCP\Controllers\LoginController.cs:line 89
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
17:29:50.859 9 N - System.ArgumentException: An item with the same key has already been added. Key: dbconn
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at XCode.DataAccessLayer.DAL.get_ConnStrs() in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 158
at XCode.DataAccessLayer.DAL..ctor(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 36
at XCode.DataAccessLayer.DAL.Create(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 72
at XCode.EntitySession1.get_Dal() in E:\X\Src\XCode\Entity\EntitySession.cs:line 118 at XCode.Entity1.FindCount(Expression where, String order, String selects, Int64 startRowIndex, Int64 maximumRows) in E:\X\Src\XCode\Entity\Entity.cs:line 816
at COMCMS.Web.Areas.AdminCP.Controllers.LoginController.Login() in D:\Projects\Github\comcms_core\COMCMS.Web\Areas\AdminCP\Controllers\LoginController.cs:line 89
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
17:30:20.170 30 N - System.ArgumentException: An item with the same key has already been added. Key: dbconn
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at XCode.DataAccessLayer.DAL.get_ConnStrs() in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 158
at XCode.DataAccessLayer.DAL..ctor(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 36
at XCode.DataAccessLayer.DAL.Create(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 72
at XCode.EntitySession1.get_Dal() in E:\X\Src\XCode\Entity\EntitySession.cs:line 118 at XCode.Entity1.FindCount(Expression where, String order, String selects, Int64 startRowIndex, Int64 maximumRows) in E:\X\Src\XCode\Entity\Entity.cs:line 816
at COMCMS.Web.Areas.AdminCP.Controllers.LoginController.Login() in D:\Projects\Github\comcms_core\COMCMS.Web\Areas\AdminCP\Controllers\LoginController.cs:line 89
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
17:30:38.586 30 N - System.ArgumentException: An item with the same key has already been added. Key: dbconn
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at XCode.DataAccessLayer.DAL.get_ConnStrs() in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 158
at XCode.DataAccessLayer.DAL..ctor(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 36
at XCode.DataAccessLayer.DAL.Create(String connName) in E:\X\Src\XCode\DataAccessLayer\DAL.cs:line 72
at XCode.EntitySession1.get_Dal() in E:\X\Src\XCode\Entity\EntitySession.cs:line 118 at XCode.Entity1.FindCount(Expression where, String order, String selects, Int64 startRowIndex, Int64 maximumRows) in E:\X\Src\XCode\Entity\Entity.cs:line 816
at COMCMS.Web.Areas.AdminCP.Controllers.LoginController.Login() in D:\Projects\Github\comcms_core\COMCMS.Web\Areas\AdminCP\Controllers\LoginController.cs:line 89
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

1111
2222

运行出错截图如上所示。

这个好像是有时候你加了调试模式,会这样。或者这样你加这个Q群,在里面把截图发出来看看是怎么回事。Q群:1600800

好的,感谢!