我在表Account和AccountProperties之间的数据库中有一对一的关系,如下所示。
CREATE TABLE Account(
[ID] [int] IDENTITY(1,1) NOT NULL,
[AccountName] [varchar](255),
CONSTRAINT [PK_Account]
PRIMARY KEY CLUSTERED ([ID] ASC)
) ON [PRIMARY]
CREATE TABLE AccountProperties(
[AccountHistoryID] [int] IDENTITY(1,1) NOT NULL,
[AccountID] [int] NOT NULL,
[Password] [varchar](50) NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AccountProperties] WITH NOCHECK
ADD CONSTRAINT [FK_AccountProperties_Account]
FOREIGN KEY([AccountID]) REFERENCES [dbo].[Account] ([ID])
我想使用外键AccountID将这两个表映射到单个实体,如下所示。
public class Account
{
[Key]
public int ID { get; set; }
public string AccountName { get; set; }
public string Password { get; set; }
}
有人可以使用流畅的API为我提供正确的映射吗?