----选择数据库 use ythome go ----查看表是否存在 if Exists ( select * from sysobjects where name='sys_menu' and type='U' ) ----删除表 begin drop table sys_menu end go create table sys_menu ( ----Primary Key 主键约束 IDENTITY(1,1) 标示列初始值1,标示增量1 [id] int not null Primary
[Key] //主键 [DatabaseGenerated(DatabaseGeneratedOption.Identity)] //设置自增 public int id { get; set; } [ForeignKey("category")] //外键 public int categoryid { get; set; } public Category category { get; set; }
primary key 主键 notnull 不为空 unique 唯一 foreign key(外键) references t1(id) auto_increment 递增,数字必须为整数 字段的增删改查 : 增 insert into t1 values(XX) 删delete from t1 where id = 1 改update t1 set name = XX where id = 1 查 select * from t1 表格的增删改 增al