草庐IT

login_context

全部标签

C# 编译器 : cannot access static method in a non-static context

我有下面的代码:publicclassAnything{publicintData{get;set;}}publicclassMyGenericBase{publicvoidInstanceMethod(Tdata){//dosomejob}publicstaticvoidStaticMethod(Tdata){//dosomejob}//othersmembers...}publicsealedclassUsefulController:MyGenericBase{publicvoidProxyToStaticMethod(){StaticMethod(null);}//others

c# - 如何防止 EF "The context cannot be used while the model is being created"错误?

查看我的Elmah错误日志,我看到一些来自EntityFramework的InvalidOperationException处理:Thecontextcannotbeusedwhilethemodelisbeingcreated.这是来自Nuget的最新EFCodeFirst库。我能够在网上找到的唯一信息是它是由将数据上下文作为单例引起的,这肯定不是我的情况。在我的Windsor安装程序中,我的EF工作单元结构正在注册:container.Register(Component.For().ImplementedBy().LifeStyle.PerWebRequest);我能够通过在VS

c# - Entity Framework 核心 : A second operation started on this context before a previous operation completed

我正在使用EntityFrameworkCore开发ASP.NetCore2.0项目在我的列表方法之一中出现了这个错误:InvalidOperationException:Asecondoperationstartedonthiscontextbeforeapreviousoperationcompleted.Anyinstancemembersarenotguaranteedtobethreadsafe.Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection()这是我的方法:[Ht

c# - "Context cannot be used while the model is being created"异常与 ASP.NET 标识

为什么当我们调用AccountApiController.Register()方法时会发生这种情况?什么试图使用上下文?什么试图创建上下文?我们如何避免这种情况?我们如何调试它?"Message":"Anerrorhasoccurred.","ExceptionMessage":"Thecontextcannotbeusedwhilethemodelisbeingcreated.ThisexceptionmaybethrownifthecontextisusedinsidetheOnModelCreatingmethodorifthesamecontextinstanceisacces

c# - 仅 Entity Framework 代码错误 : the model backing the context has changed since the database was created

我使用EntityFramework4和CTP4创建了一个“仅限代码”的POCO,用于针对现有数据库。当我运行查询时出现错误Themodelbackingthe'xyzContext'contexthaschangedsincethedatabasewascreated.Eithermanuallydelete/updatethedatabase,orcallDatabase.SetInitializerwithanIDatabaseInitializerinstance.Forexample,theRecreateDatabaseIfModelChangesstrategywilla

c# - EF 5 启用迁移 : No context type was found in the assembly

我有4个项目:Toombu.Entities:allmodelsarethereToombu.DataAccess:Mapping,RepositoryandToombuContextToombu.Logique:LogicofmyapplicationToombu.Web:MVC4application.WithallothersDLL.我尝试在Toombu.Web中启用迁移,但出现此错误:Nocontexttypewasfoundintheassembly如何启用迁移? 最佳答案 令我惊讶的是,没有人提到这个问题的明显答案:En

docker - 拉取访问被拒绝的存储库不存在或可能需要 docker login

我正在使用Laravel4.2和docker。我在本地设置。它没有任何问题,但是当我尝试使用相同的程序进行在线设置时,我收到了错误:pullaccessdeniedfor/php,repositorydoesnotexistormayrequire'dockerlogin'在此处创建存储库是否相关https://cloud.docker.com/还是需要dockerlogin命令?经过几天的研究,我仍然无法弄清楚在这种情况下可以解决什么问题以及正确的步骤是什么?我有完整的代码。如果需要检查某些部分,我可以在这里粘贴。 最佳答案 请注

docker - 拉取访问被拒绝的存储库不存在或可能需要 docker login

我正在使用Laravel4.2和docker。我在本地设置。它没有任何问题,但是当我尝试使用相同的程序进行在线设置时,我收到了错误:pullaccessdeniedfor/php,repositorydoesnotexistormayrequire'dockerlogin'在此处创建存储库是否相关https://cloud.docker.com/还是需要dockerlogin命令?经过几天的研究,我仍然无法弄清楚在这种情况下可以解决什么问题以及正确的步骤是什么?我有完整的代码。如果需要检查某些部分,我可以在这里粘贴。 最佳答案 请注

c# - 错误 : "The specified LINQ expression contains references to queries that are associated with different contexts"

我从LINQ查询中收到标题中显示的错误,该查询包含来自两个不同edmx文件的两个表。这是查询:varquery=(fromaindb1.Table1joinbindb1.Table2ona.Idequalsb.Idorderbya.Statuswhereb.Id==1&&a.Status=="new"selectnew{Id=a.Id,CompanyId=(fromcindb2.Companywheres.Id==a.Idselectnew{c.CompanyId})});db1和db2是与两个不同的edmx文件关联的上下文。我该如何克服这个错误? 最佳答案

c# - Entity Framework Context 是否应该放在 Using 语句中?

EntityFramework上下文对象实现了一个Dispose()方法,该方法“释放对象上下文使用的资源”。它到底有什么作用?总是把它放在using{}语句中会不会是一件坏事?我已经看到它在有和没有using语句的情况下都被使用。我特别打算在WCF服务方法中使用EF上下文,创建上下文,执行一些linq并返回答案。编辑:似乎我不是唯一对此感到疑惑的人。另一个问题是Dispose()方法内部到底发生了什么。有人说它会关闭连接,而有些文章则说不会。怎么回事? 最佳答案 如果你创建了一个上下文,你必须稍后处理它。是否应该使用using语句