for (int i = 0; i < 2000; i++)
{
//ThreadStart threadStart = new ThreadStart(dddd);
Thread thread = new Thread(new System.Threading.ParameterizedThreadStart(dddd));
thread.Start(i);
// dddd(0);
Console.WriteLine(i);
}
using (var cc = new EfDbContext("Xiaoyujia"))
{
cc.Set<OrderOperationLog>().Add(OrderOperationLog);
cc.SaveChanges();
}
怎么个挂法?
l连接数超出
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
@conan_lin: 这个有啥好解决的.
并发连接数不够不是很正常吗?
至于你说的ado.net不会.是因为还没到量级
@吴瑞祥: 主要是同等环境下 两个的量级差别大
@conan_lin: 这个是肯定的.尤其是你一次数据库连接中的操作简单的时候.
EF封装了很多东西.所以他的单次简单操作的复杂度就比ado.net高很多.
如果你把一次数据库操作的复杂度提高.比如批量插入10000个数据 两边的差距就没那么明显了.
加上这个试试
public class EFDbContextFactory
{
public static DbContext GetCurrentDbContext()
{
//单例模式:保证线程实例唯一
DbContext db = (DbContext)CallContext.GetData("DbContext");
if (db == null)
{
db = new Nee32Entities();
CallContext.SetData("DbContext", db);
}
return db;
}
}
不是这个的问题
SQL SERVER也有最大同时连接数
改了 没用