我有两张桌子
CREATE TABLE Company (
Id uniqueidentifier primary key not null,
CompanyName nvarchar(100) not null)
GO
CREATE TABLE Feature (
Id uniqueidentifier primary key not null,
CompanyId uniqueidentifier not null,
Feature1 bit not null,
Feature2 bit not null)
GO
如何通过数据库上的 CompanyId 字段和 EF Code First 端与配置文件建立一对一的关系
课程:
public class Company
{
private Guid id = Guid.NewGuid();
public virtual Guid Id
{
get { return id; }
set { id = value; }
}
public virtual string CompanyName { get; set; }
}
public class Feature
{
private Guid id = Guid.NewGuid();
public virtual Guid Id
{
get { return id; }
set { id = value; }
}
public virtual Company Company { get; set; }
public virtual bool Feature1 { get; set; }
public virtual bool Feature2 { get; set; }
}