本文整理汇总了C#中ModelBuilder.ForSqlServer方法的典型用法代码示例。如果您正苦于以下问题:C# ModelBuilder.ForSqlServer方法的具体用法?C# ModelBuilder.ForSqlServer怎么用?C# ModelBuilder.ForSqlServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelBuilder
的用法示例。
在下文中一共展示了ModelBuilder.ForSqlServer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnModelCreating
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ForSqlServer().UseIdentity();
builder.Entity<User>().Table("Users");
builder.Entity<List>().Table("Lists");
builder.Entity<Good>().Table("Goods");
builder.Entity<ListGood>().Table("ListsGoods");
builder.Entity<UserFriend>().Table("UsersFriends");
builder.Entity<ListShare>().Table("ListsShares");
builder.Entity<UserFriend>().Key(uf => new { uf.UserId, uf.FriendId });
builder.Entity<ListShare>().Key(ls => new { ls.ListId, ls.UserId });
base.OnModelCreating(builder);
}
示例2: OnModelCreating
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ForSqlServer().UseIdentity();
builder.Entity<Category>()
.Reference(c => c.ParentCategory)
.InverseCollection(c => c.Children)
.ForeignKey(c => c.ParentCategoryId);
builder.Entity<OrderLine>()
.Key(ol => new { ol.OrderId, ol.ProductId });
builder.Entity<OrderShippingDetails>()
.Key(d => d.OrderId);
builder.Entity<Order>()
.Reference(o => o.ShippingDetails)
.InverseReference()
.ForeignKey<OrderShippingDetails>(d => d.OrderId);
builder.Entity<OrderShippingDetails>().ConfigureAddress();
builder.Entity<CartItem>().Property<DateTime>("LastUpdated");
}
示例3: OnModelCreating
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ForSqlServer().UseIdentity();
base.OnModelCreating(builder);
}
示例4: OnModelCreating
public override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ForSqlServer().UseIdentity();
}