1
錯誤在於:模型創建時無法使用上下文。創建模型時無法使用上下文
我使用這個代碼:
Parallel.Invoke(AddDataParallel);
private void AddDataParallel()
{
Parallel.For(1001, 2001, delegate(int i)
{
User user = new User();
user.UserName = "user" + i;
_userService2.Add(user);
});
}
錯誤:
public T Add(T entity)
{
return _entities.Add(entity);//The context cannot be used while the model is being created.
}
爲什麼呢?