【问题标题】:when using entity framework model first, how to map string with different db types首先使用实体​​框架模型时,如何将字符串映射到不同的数据库类型
【发布时间】:2014-06-30 08:59:44
【问题描述】:

例如:

public string Name { get; set;}
public string Comment { get; set;}

如何用 nvarchar(20) 映射 Name,用 nvarchar(500) 映射 Comment?

【问题讨论】:

    标签: c# entity-framework orm ef-model-first


    【解决方案1】:

    你可以加Column

    这样的属性;

    [Column(DbType="NVarChar(20)")]
    public string Name { get; set;}
    [Column(DbType="NVarChar(500) NOT NULL")]
    public string Comment { get; set;}
    

    SQL-CLR Type Mapping

    【讨论】:

      猜你喜欢
      • 2010-09-24
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      • 2016-08-31
      • 2013-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多