我有两个 SQL 表:
Users ( Id, Username )
Profiles ( Id, UserId, Email )
我有两节课:
public class User
{
[Key]
public int Id { get; set; }
public string Username { get; set; }
public Profile profile { get; set; }
}
public class Profile
{
//[Key]
//public int Id { get; set; }
public string Email { get; set; }
}
我有一个选择用户和配置文件作为 JOIN 的视图:
CREATE VIEW [dbo].[Users]
AS SELECT
AspNetUsers.UserName,
UserProfiles.*
FROM [AspNetUsers]
INNER JOIN UserProfiles ON AspNetUsers.Id = UserProfiles.UserId
我如何(在类中)将用户与配置文件相关联,以便我可以使用 EntityFramework 控制器/视图 crud 构建器?