Omu*_*Omu 4 entity-framework-4
我和many-to-many之间有关系FooBar
这是一个简化的Foo
public class Foo
{
public virtual ICollection<Bar> Bars {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我想保存一个附带一些条形的新foo:
var foo = new Foo();
foo.Bars.Add(bar1); //I'll get an error that if Bars is not initialized
repo.Insert(foo);
repo.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
我应该在构造函数中初始化Bars,这应该怎么做?(使用EF4 CTP5 codefirst)