小编beg*_*boy的帖子

JSON Serializer尝试访问一个早已消失的EntityFramework上下文,对于我没有要求的数据,或者关心

我想做什么?

我正在向我的C#Backend(MSSQL + EF6)发送API调用,

http://localhost:56680/api/Booking/Countries
Run Code Online (Sandbox Code Playgroud)

此API调用的关注点是从我的数据库中获取国家/地区.

SQL数据库表结构

我从我的数据库中包含屏幕截图的原因是因为汽车是这里的麻烦制造者.

国家和汽车彼此之间有许多关系,由CountryCars(基本上是Vignettes)代表.


这些是相应的域模型:

Car.cs

public class Car
{
    public int Id { get; set; }
    public Guid GUID { get; set; }
    public string Model { get; set; }
    public virtual VehicleType VehicleType { get; set; } 
    public virtual Location Location { get; set; }
    [StringLength(255)]
    [Index(IsUnique=true)]
    public string LicensePlate { get; set; }
    public int NrOfSeats { get; set; }
    public Equipment Equipment { get; set; }
    public virtual ICollection<Country> Vignette { get; …
Run Code Online (Sandbox Code Playgroud)

c# json entity-framework json.net

1
推荐指数
1
解决办法
112
查看次数

标签 统计

c# ×1

entity-framework ×1

json ×1

json.net ×1