我有以下POCO类自动生成主键(GUID)实体框架CTP5
public class Account
{
[Key,DatabaseGenerated(DatabaseGenerationOption.Identity)]
public string AccountId { set; get; }
public string FirstName { set; get; }
public string LastName { set; get; }
public string Email { set; get; }
}
我得到下面的异常当数据库被创建
Identity column 'AccountId' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, and constrained to be nonnullable.
注意:如果您在模型类中使用“保留”标识列名称“Id”,即使您有'[Key,DatabaseGenerated(...)]' - 也必须重新命名把你的模型中的你的身份财产转移到别的东西上,比如在这种情况下,'AccountId'。 – rdev5 2016-09-22 20:11:22