首页 > 数据库技术 > 详细

db first执行时说model没有key

时间:2017-10-11 22:14:27      阅读:265      评论:0      收藏:0      [点我收藏+]

原因:自动生成的类中有关联主键,没有自动生成Key及Column

解决方法:在xxx.tt的66行左右修改为

var simpleProperties = typeMapper.GetSimpleProperties(entity);
if (simpleProperties.Any())
{
    var keyIndex = 0; // This is a new line
    foreach (var edmProperty in simpleProperties)
    {
        // The following if block is new
        if (ef.IsKey(edmProperty)) 
        {
#>          [System.ComponentModel.DataAnnotations.Key]
            [System.ComponentModel.DataAnnotations.Schema.Column(Order = <#=keyIndex.ToString()#>)]
<#
            keyIndex++;
#>
<#      }
#>
        <#=codeStringGenerator.Property(edmProperty)#>
<#
    }
}

  

db first执行时说model没有key

原文:http://www.cnblogs.com/punkrocker/p/7653150.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!