实体框架使用列映射对象

时间:2016-05-22 12:46:58

标签: c# entity-framework asp.net-web-api entity-framework-6 dbcontext

我使用EF6。我有一个<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <meta charset='utf-8'> </head> <body> <div class="contentarea"> <div class="camera"> <video id="video">Video stream not available.</video> <button id="startbutton">Take photo</button> </div> <canvas id="canvas"> </canvas> <div class="output"> <img id="photo" alt="The screen capture will appear in this box."> </div> </div> </body> </html>和一个Person类:

Friend

我有两张桌子:

  1. Id整数
  2. 名称varchar
  3. FriendId整数
  4. 朋友

    1. Id整数
    2. 名称varchar
    3. 我希望EF public class Person { public int Id { get; set; } public string Name { get; set; } public Friend { get; set; } } public class Friend { public int Id { get; set; } public string Name { get; set; } } DBContext列与FriendId类中的Friend对象进行映射。

      创建Person实例时,我希望EF创建Person个实例,并在Friend列中设置FriendId

      有可能还是我做错了?我是否必须将Person(FriendId)属性替换为int Friend

      谢谢

0 个答案:

没有答案