.net - Entity Framework 中的固定长度字符串?

标签 .net entity-framework entity-framework-6

有没有办法在 EF (6.1) 中设置字段的长度?

我希望将以下属性生成为 char(2) :

public string LanguageId { get; set; }

最佳答案

你可以结合 TypeNameStringLength :

[Column(TypeName = "char")]
[StringLength(2)]
public string LanguageId { get; set; }

在 SQL Server 中,它应该生成一个 char(2)柱子。

关于.net - Entity Framework 中的固定长度字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24844768/

相关文章:

c# - 依赖任务图 : neat parallel execution in . 网络?

.net - Bin 部署 rake(和 IronRuby)

c# - 如何在 ASP.NET MVC 5、Entity Framework 6 中使用流畅的 API 映射表?

c# - 如何使用 log4net 记录 EF 生成的 SQL

.net - 用于 .NET 的 PHP

c# - 理解给定的计算(cast + multiplication)

c# - 使用继承自 IdentityDbContext 的上下文对 Entity Framework 6 进行单元测试

c# - 具有自定义端点名称的 WEB API .NET 操作

MySQL IO操作超时

entity-framework - EntityFramework 中 IdentyUsers 的集合 - 没有定义键