简体   繁体   English

首先使用实体​​框架模型时,如何映射具有不同数据库类型的字符串

[英]when using entity framework model first, how to map string with different db types

for example: 例如:

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

How to map Name with nvarchar(20) and map Comment with nvarchar(500)? 如何使用nvarchar(20)映射Name和使用nvarchar(500)映射Comment?

You can add Column 您可以添加Column

attribute like this; 这样的属性;

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

SQL-CLR Type Mapping SQL-CLR类型映射

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Entity Framework将POCO模型类映射到现有数据库表 - How do I map POCO model classes to existing DB tables using Entity Framework 实体框架数据库优先-模型中的继承问题 - Entity Framework DB First - Problems with inheritance in the model 使用模型优先生成代码时出现实体框架错误 - Entity Framework error when using Model First to generate code 更改实体框架中的连接字符串(模型优先) - Change connection string in Entity Framework(Model First) 如何将 WPF 模型映射到实体框架模型 - How to Map WPF Model To Entity Framework Model 如何使用SQL映射具有列表属性的实体框架模型 - How to map an Entity Framework model that has a list property using SQL 如何将同一实体映射到不同的数据库并仅忽略 Entity Framework Core 中的一个数据库的列? - How to map same entity to different databases and ignoring a column only for one DB in Entity Framework Core? Entity Framework Core DB先行,如何在不同的C#核心项目中添加实体关联 - Entity Framework Core DB first, How to add an entity association in different C# core projects 首先在不同架构中映射具有相同表的实体 Entity Framework 6 代码 - Map entity with same table in different schemas Entity Framework 6 code first 如何使用实体框架将属性映射到不同的表 - How to map a property to a different table using Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM