SqlServer教程

sql server 2008所有类型对应ef自动生成的约束和实体属性

本文主要是介绍sql server 2008所有类型对应ef自动生成的约束和实体属性,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

数据库:

Id uniqueidentifier Unchecked
a1 bigint Checked
a2 binary(50) Checked
a3 bit Checked
a4 char(10) Checked
a5 date Checked
a6 datetime Checked
a7 datetime2(7) Checked
a8 datetimeoffset(7) Checked
a9 decimal(18, 0) Checked
a10 float Checked
a11 geography Checked
a12 geometry Checked
a13 hierarchyid Checked
a14 image Checked
a15 int Checked
a16 money Checked
a17 nchar(10) Checked
a18 ntext Checked
a19 numeric(18, 0) Checked
a20 nvarchar(50) Checked
a21 nvarchar(MAX) Checked
a22 real Checked
a23 smalldatetime Checked
a24 smallint Checked
a25 smallmoney Checked
a26 sql_variant Checked
a27 text Checked
a28 time(7) Checked
a29 timestamp Checked
a30 tinyint Checked
a31 uniqueidentifier Checked
a32 varbinary(50) Checked
a33 varbinary(MAX) Checked
a34 varchar(50) Checked
a35 varchar(MAX) Checked
a36 xml Checked

 

 

对应的实体:

public Guid Id { get; set; }

public long? a1 { get; set; }

[MaxLength(50)]
public byte[] a2 { get; set; }

public bool? a3 { get; set; }

[StringLength(10)]
public string a4 { get; set; }

[Column(TypeName = "date")]
public DateTime? a5 { get; set; }

public DateTime? a6 { get; set; }

[Column(TypeName = "datetime2")]
public DateTime? a7 { get; set; }

public DateTimeOffset? a8 { get; set; }

public decimal? a9 { get; set; }

public double? a10 { get; set; }

public DbGeography a11 { get; set; }

public DbGeometry a12 { get; set; }

[Column(TypeName = "image")]
public byte[] a14 { get; set; }

public int? a15 { get; set; }

[Column(TypeName = "money")]
public decimal? a16 { get; set; }

[StringLength(10)]
public string a17 { get; set; }

[Column(TypeName = "ntext")]
public string a18 { get; set; }

[Column(TypeName = "numeric")]
public decimal? a19 { get; set; }

[StringLength(50)]
public string a20 { get; set; }

public string a21 { get; set; }

public float? a22 { get; set; }

[Column(TypeName = "smalldatetime")]
public DateTime? a23 { get; set; }

public short? a24 { get; set; }

[Column(TypeName = "smallmoney")]
public decimal? a25 { get; set; }

[Column(TypeName = "text")]
public string a27 { get; set; }

public TimeSpan? a28 { get; set; }

[Column(TypeName = "timestamp")]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
[MaxLength(8)]
public byte[] a29 { get; set; }

public byte? a30 { get; set; }

public Guid? a31 { get; set; }

[MaxLength(50)]
public byte[] a32 { get; set; }

public byte[] a33 { get; set; }

[StringLength(50)]
public string a34 { get; set; }

public string a35 { get; set; }

[Column(TypeName = "xml")]
public string a36 { get; set; }

 

对应生成的约束:

modelBuilder.Entity<Test1>()
.Property(e => e.a2)
.IsFixedLength();

modelBuilder.Entity<Test1>()
.Property(e => e.a4)
.IsFixedLength()
.IsUnicode(false);

modelBuilder.Entity<Test1>()
.Property(e => e.a9)
.HasPrecision(18, 0);

modelBuilder.Entity<Test1>()
.Property(e => e.a16)
.HasPrecision(19, 4);

modelBuilder.Entity<Test1>()
.Property(e => e.a17)
.IsFixedLength();

modelBuilder.Entity<Test1>()
.Property(e => e.a19)
.HasPrecision(18, 0);

modelBuilder.Entity<Test1>()
.Property(e => e.a25)
.HasPrecision(10, 4);

modelBuilder.Entity<Test1>()
.Property(e => e.a27)
.IsUnicode(false);

modelBuilder.Entity<Test1>()
.Property(e => e.a29)
.IsFixedLength();

modelBuilder.Entity<Test1>()
.Property(e => e.a34)
.IsUnicode(false);

modelBuilder.Entity<Test1>()
.Property(e => e.a35)
.IsUnicode(false);

这篇关于sql server 2008所有类型对应ef自动生成的约束和实体属性的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!