捕捉到 System.Data.Entity.Infrastructure.DbUpdateException
HResult=-2146233087
Message=无法更新 EntitySet“order”,因为它有一个 DefiningQuery,而 <ModificationFunctionMapping> 元素中没有支持当前操作的 <InsertFunction> 元素。
Source=EntityFramework
StackTrace:
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
在 System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
在 System.Data.Entity.DbContext.SaveChanges()
在 kxhSellerMobile.Models.DAO.OrderDAO.CreateQRcodeOrder(Int32 _userID) 位置 d:\WebSite\kxhSellerMobile\kxhSellerMobile\Models\DAO\OrderDAO.cs:行号 32
InnerException: System.Data.UpdateException
HResult=-2146233087
Message=无法更新 EntitySet“order”,因为它有一个 DefiningQuery,而 <ModificationFunctionMapping> 元素中没有支持当前操作的 <InsertFunction> 元素。
Source=System.Data.Entity
StackTrace:
在 System.Data.SqlClient.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression)
在 System.Data.Common.CommandTrees.DbScanExpression.Accept(DbExpressionVisitor visitor)
在 System.Data.SqlClient.SqlGen.DmlSqlGenerator.GenerateInsertSql(DbInsertCommandTree tree, SqlVersion sqlVersion, List`1& parameters)
在 System.Data.SqlClient.SqlGen.SqlGenerator.GenerateSql(DbCommandTree tree, SqlVersion sqlVersion, List`1& parameters, CommandType& commandType, HashSet`1& paramsToForceNonUnicode)
在 System.Data.SqlClient.SqlProviderServices.CreateCommand(DbProviderManifest providerManifest, DbCommandTree commandTree)
在 System.Data.SqlClient.SqlProviderServices.CreateCommand(DbCommandTree commandTree)
在 System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
在 System.Data.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(UpdateTranslator translator, Dictionary`2 identifierValues)
在 System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
在 System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
在 System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
在 System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
InnerException:
Solution:实体对象对应的表没有主键,把主键添加上去
2.有时从站点上下载下来的apk ,但手机点apk安装包却装不了,反而像zip压缩包那样打开,看到了一些文件,如下图:
解决方法:http://www.cr173.com/html/18996_1.html
或直接控制器上写:
public ActionResult Download(string id) { return File(Server.MapPath("~/File/" + id), id.EndsWith("apk") ? "application/vnd.android.package-archive" : "application/octet-stream"); }
</pre><pre code_snippet_id="533831" snippet_file_name="blog_20141126_2_8280343" name="code" class="csharp">3..net下用oracle连接数据库(EF方式)出现下面错误:
<h3 style="font-size: 1.4em; margin: 10px 0px 0px; color: rgb(204, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif;">HTTP 错误 500.19 - Internal Server Error</h3><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11.1999998092651px;">无法读取配置节“oracle.manageddataaccess.client”,因为它缺少节声明</span>
<span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11.1999998092651px;">解决方法:在configuration下添加节点:
</span>
<span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11.1999998092651px;"></span><pre name="code" class="html"> <configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
4.未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。
解决方法:检查packages文件夹下是否有Newtonsoft.Json程序集,有的话
打开工程文件 .csproj ,看看引用Newtonsoft.Json程序集的packages路径是否正确,如果也正确,则删除这条引用记录,重新添加引用或重装json.net程序集
参考:
http://www.fineui.com/bbs/forum.php?mod=viewthread&tid=6154
http://stackoverflow.com/questions/21498074/how-can-i-fix-assembly-version-conflicts-with-json-net-after-updating-nuget-pack
http://stackoverflow.com/questions/17776090/newtonsoft-json-assembly-conflict