public class User {
int Id { set; get; } // autogenerated on insert
public string Username { set; get; }
}
然后在我的代码中的一些地方我有以下内容:
var user = new User();
user.Username = string.Format("user{0}", user.Id);
dbContext.User.Add(user);
dbContext.SaveChanges();
Debug.WriteLine(user.Username); // outputs "User0" when the Id is ..not 0