2016-06-13 5 views
1

複雑なプロジェクトにジャンプしなければならず、WEB APIサービスで特定のリポジトリの単体テストを作成しています。データベースCRUDは、Entity Frameworkによって処理されます。テーブルが存在するときに無効なオブジェクト名を指定するEntity Framework

private class IntegrationScope : AutoRollbackTransactionTestScope<DocumentRepository> 
    { 
     public IntegrationScope() 
     { 
      DependencyResolverMock = MockDependencyResolverFor<IResourceUrlBuilder, ResourceUrlBuilder>(new ResourceUrlBuilder()); 
      LoggingProviderMock = new Mock<ILoggingProvider>(); 

      // use real document micro service AutoMapper & Unity configuration 
      AutoMapperConfig.RegisterMaps(Mapper.Configuration, DependencyResolverMock); 
      UnityConfig.RegisterTypes(TestScopeContainer); 

      //Set the DomainId 
      TestId = Guid.NewGuid(); 

      TestDocument = BuildDocument(TestId); 

      // get the real object 
      DocumentStoreDbContext = TestScopeContainer.Resolve<IDocumentDbContext>(); 

      InstanceUnderTest = new DocumentRepository(DocumentStoreDbContext); 
     } 

     public static Web.Service.DocumentStore.Domain.Document BuildDocument(Guid documentId) 
     { 
      // Invoke GetBytes method. 
      byte[] array = Encoding.ASCII.GetBytes("Byte Repository Test"); 

      return Builder<Web.Service.DocumentStore.Domain.Document> 
       .CreateNew() 
       .With(t => t.Id = documentId) 
       .With(t => t.Data = array) 
       .Build(); 
     } 

それはDocumentStoreDbContextラインになると、コンパイル・エラーがありませんが、私は、オブジェクト名が無効であることを言って、ランタイムエラーを取得する:いくつかの研究これを実行した後

enter image description here

エラーは、データベース/テーブルが存在しないので、しかし、私はそれが存在しないことを確認することができますように表示されます。

enter image description here

私は間違って何をしていますか、どうすれば修正できますか?

+0

テーブルがエンティティモデルで正しくマップされていることを確認しましたか? – derloopkat

答えて

1

InnerExceptionはテーブル名をDocumentStore.Documentsと表示しますが、SSMSのスクリーンショットはdbo.Documentsと表示されます。

原因が考えられますか?

関連する問題