Ok,thank you!
hi hikalkan, I have single shared db for 2 dbcontextes and unit test can run correctly. My 2nd dbcontext has the costructor takes DbConnection like below:
public class SecondHWWLDbContext : AbpDbContext {
public virtual IDbSet<Notification> Notifications { get; set; }
public SecondHWWLDbContext()
: base("Second")
{
}
public SecondHWWLDbContext(string secondNameOrConnectionString)
: base(secondNameOrConnectionString)
{
}
public SecondHWWLDbContext(DbConnection dbConnection)
: base(dbConnection, true)
{
}
}
Stack trace is like below: at Abp.EntityFramework.AbpDbContext.SaveChanges() location e:\Abp\trunk\Abp+Zero+HWWL\Abp.EntityFramework\EntityFramework\AbpDbContext.cs:line 190 at AndHuang.HWWL.TestDatas.LMTestDataBuilder.Create() location e:\Abp\trunk\Abp+Zero+HWWL\AndHuang.HWWL.Tests\TestDatas\LMTestDataBuilder.cs:line 42 at AndHuang.HWWL.Tests.AppTestBase.<.ctor>b__1(SecondHWWLDbContext secondSontext) location e:\Abp\trunk\Abp+Zero+HWWL\AndHuang.HWWL.Tests\AppTestBase.cs:line 45 at AndHuang.HWWL.Tests.AppTestBase.UsingDbContext[TDbContext](Action`1 action) location e:\Abp\trunk\Abp+Zero+HWWL\AndHuang.HWWL.Tests\AppTestBase.cs:line 77 at AndHuang.HWWL.Tests.AppTestBase..ctor() location e:\Abp\trunk\Abp+Zero+HWWL\AndHuang.HWWL.Tests\AppTestBase.cs:line 43 at AndHuang.HWWL.Bills.Bill_Tests..ctor() location e:\Abp\trunk\Abp+Zero+HWWL
Anybody can help me?
Thanks a lot , it gave me much help.
Stack Trace is like below: [External code]
Abp.EntityFramework.dll!Abp.EntityFramework.AbpDbContext.Initialize() line 137 C# [External code] Abp.dll!Abp.Dependency.IocManager.Resolve<AndHuang.HWWL.EntityFramework.HWWLDbContext>() line 159 C# AndHuang.HWWL.dll!AndHuang.HWWL.Tests.AppTestBase.UsingDbContext(System.Action<AndHuang.HWWL.EntityFramework.HWWLDbContext> action) line 67 C# AndHuang.HWWL.dll!AndHuang.HWWL.Tests.AppTestBase.AppTestBase() line 34 C# AndHuang.HWWL.dll!AndHuang.HWWL.Test.Sms.SmsManager_Tests.SmsManager_Tests() line C# [External code]
I viewed the link you provided ,I guess it may be a bug of EF CodeFirst. .