Fluent API
class MyContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>()
.HasKey(b => b.BlogId)
.HasName("PrimaryKey_BlogId");
}
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
}
一个每日更新的干货公众号
网友评论