zoukankan      html  css  js  c++  java
  • 开发过程遇到的问题和解决方法(备忘)

    2015-03-19

    1.当项目框架为.Net Framework4.0的时候,使用EF6.0会出问题。

    解决方法:将引用的EF相关dll改成EF5.0的DLL。

    2.EF使用Model First方式建立数据库时,发布网站至IIS或者服务器上时,微软会采取sql登录验证而采取Windows(即连接字符串为Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=true; 时会出问题)

    解决方法:将EF的连接字符串改为

    1 <add name="Model1Container" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=./;Initial Catalog=kashishop;User Id=kashishop;Password=123;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

    3.使用EF,发布网站时,要在配置文件中添加

    1 <configSections>
    2     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    3     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    4   </configSections>

    1 <entityFramework>
    2     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
    3       <parameters>
    4         <parameter value="v11.0" />
    5       </parameters>
    6     </defaultConnectionFactory>
    7   </entityFramework>

     2015-03-21

    1.unity工程中添加多个相机后出现如下警告:
    There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
    解决办法:将后添加相机的Audio Listener移除
     
    2.unity build项目的时候报错如下:
    网上搜了半天,终于找到原因,是因为用了NGUI的Label,Font属性选了个不存在的字体,不知道为什么unity会将一个不存在不支持的字体显示在选择栏,好坑爹。
     
    2015-04-08
    1.给EF的实体建立导航对象时,在更新实体对象时,报错“一个实体对象不能由多个 IEntityChangeTracker 实例引用”。
    这个错误信息是由于在添加了导航属性时,必须由同一个上下文对象对实体进行更新,比如说
     
    1                 GoodService gs = new GoodService();
    2                 Good g = gs.LoadEntities(u => u.Id == id).FirstOrDefault();
    3                 g.Name = name;
    4                 g.Price = double.Parse(price);
    5                 g.Quantifier = quantifier;
    6                 g.Instruction = instruction;
    7                 g.TypeId = typeId;
    8                 gs.Update(g);

    把Service提前,用同一个Service进行取值和更新操作就没问题。

    但是像下面这样,用不同的Service对象对同一个实体的导航对象进行更新就会报此错误。

    1                 Good g = new GoodService().LoadEntities(u => u.Id == id).FirstOrDefault();
    2                 g.Name = name;
    3                 g.Price = double.Parse(price);
    4                 g.Quantifier = quantifier;
    5                 g.Instruction = instruction;
    6                 g.TypeId = typeId;
    7                 GoodService gs = new GoodService();
    8                 gs.Update(g);

    使用EF更新数据时,如果要更新的对象有相关的对象(换句话说,就是要更新的表有主外键关系,或者导航关系),这些对象必须来自同一个IEntityChangeTracker 。

  • 相关阅读:
    msp430入门编程25
    msp430入门编程24
    msp430入门编程23
    msp430入门编程22
    msp430入门编程21
    msp430入门编程20
    msp430入门编程16
    msp430入门编程15
    msp430入门编程14
    msp430入门编程13
  • 原文地址:https://www.cnblogs.com/sunniest/p/4351860.html
Copyright © 2011-2022 走看看