2011-07-13 11 views
3

SQL CE4を使用しているデータベースで、テスト用にxunitとTestDriven.Netの両方を試しています。ここではエンティティ定義である:Entity FrameworkコードファーストとSQLServer Compact 4.0を使用する場合、「既定値はサポートされていません」エラー

public class Product 
    { 
     private readonly ICollection<Inventory> inventories = new List<Inventory>(); 
     private int id; 

     public virtual int Id { get; set; }   

     //public virtual string ProductName { get; set; } 

     public virtual ICollection<Inventory> Inventories 
     { 
      get { return inventories; } 
     } 
    } 

    public class ProductConfiguration : EntityTypeConfiguration<Product> 
    { 
     public ProductConfiguration() 
     { 
      HasKey(p => p.Id); //Id column of the product is an Identity column 

      Property(p => p.Id); 
     } 
    } 

そして、ここで試験方法である:TestDrivenはメッセージで失敗しながら

[Fact] 
    public void WhenProductAddedItShouldPersist() 
    { 
     var product= ObjectMother.Single<Product>(); 
     productRepository.Add(product); 
     unitOfWork.Commit(); 
     Assert.NotNull(productRepository.One(product.Id)); 
    } 

xUnitのメソッドを渡す - 「System.NotSupportedException:デフォルトの値がサポートされていません」。

驚いたことに、エンティティ(商品名など)に別のプロパティを追加すると、TestDrivenも合格します。誰が私にこれが起こっているのか何か手がかりを与えることができますか?

+0

これはあなたの質問に対する答えではないかもしれませんが、Dev Magic Fakeを使ってEFやDBを使用せずにTDDの作業に別のアプローチがありますhttp://devmagicfake.codeplex.com/ –

答えて

関連する問題