0
我在應用程序中遇到麻煩。我有一個MVC應用程序查詢數據庫(和一些Web服務),並以JSON返回我的信息。在我的本地計算機上工作就像一個魅力,但是當我將其上傳到網絡服務器時,出現此錯誤:在網絡服務器中序列化模型時出錯
「在'System.Data.Objects.DataClasses.RelationshipManager'上從'_owner'獲取值時出錯。 (你可以看到整個錯誤頁面中http://canedroid.com/mvc/api/requests/getlastcheckins)
我嘗試禁用代理和延遲加載有:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.Configuration.LazyLoadingEnabled = false;
base.Configuration.ProxyCreationEnabled = false;
}
並沒有任何反應。
型號:
namespace CaneDroid.MVCApp.Models
{
public class CaneDroidContext : DbContext,ICaneDroidDataSource
{
public CaneDroidContext()
: base("DefaultConnection")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.Configuration.LazyLoadingEnabled = false;
base.Configuration.ProxyCreationEnabled = false;
}
public DbSet<Checkin> mdlCheckins { get; set; }
public DbSet<configAndroid> configAndroid { get; set; }
IQueryable<Checkin> ICaneDroidDataSource.Checkins
{
get { return mdlCheckins; }
}
}
public class Checkin
{
public Checkin()
{
visto = false;
}
[Key,DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public virtual int Id { get; set; }
[Required]
public virtual string fsqCheckinId { get; set; }
public virtual string text { get; set; }
public virtual string usrId { get; set; }
public virtual string usrFrstName { get; set; }
public virtual string usrLstName { get; set; }
public virtual string venueId { get; set; }
public virtual string venueName { get; set; }
public virtual string venueAddress { get; set; }
public virtual string venueCrossStreet { get; set; }
public virtual string venueLat { get; set; }
public virtual string venueLng { get; set; }
public virtual string venueCity { get; set; }
public virtual bool visto { get; set; }
}
public class configAndroid
{
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public virtual int Id { get; set; }
public string key { get; set; }
public bool value { get; set; }
}
}
動作控制器:
public R getLastCheckins()
{
var responseJson = R.getLastCheckins(db);
return responseJson;
}
public static R getLastCheckins(CaneDroidContext db)
{
var cache = db.mdlCheckins.OrderByDescending(q => q.Id).Take(10);
return new R(cache, null, null, null, null, null);
}
,我不知道還有什麼能做些什麼。