views:

219

answers:

0

Hi I'm new to EF 4.0 and I'm trying to use POCO (VS 2010 beta 2) I did everything like it is described in ADO.NET Team blog:
1. Generated edmx from my db
2. Created POCO classes in separate project. The root class looks like this:

public class SendHistoryItem:AggregateRootObject {

    #region Scalar
    public virtual DateTime SendDate { get; set; }
    public virtual DateTime OriginalDate { get; set; }
    public virtual string UserName { get; set; }
    public virtual bool Resend { get; set; } 
    #endregion
    #region Navigation
    public virtual ICollection<FileSendItem> FileSendItems { get; set; }
    public virtual ICollection<AreaDestination> AreaDestinations { get; set; }
    #endregion
}   

AAggregateRootObject is an implementation of root EntityObject with one mapped property - ID
3. After that I tried to test saving new instance of this class in this sipmle scenario:

using (var entityModelManager = new ModelDataContext()) {

                   var sendHistoryItemFactory = entityModelManager.GetFactory<SendHistoryItem>();  
                Assert.IsNotNull(sendHistoryItemFactory);  
                var fileSendItemFactory = entityModelManager.GetFactory<FileSendItem>();  
                Assert.IsNotNull(fileSendItemFactory);                   
                var repository = entityModelManager.SendHistoryItemRepository;
                Assert.IsNotNull(repository);
                #region Create
                SendHistoryItem newItem = sendHistoryItemFactory.CreateObject();                    
                Assert.IsNotNull(newItem);
                Assert.IsTrue(newItem.IsTransient);
                newItem.AreaDestinations = new List<AreaDestination>();
                newItem.FileSendItems = new List<FileSendItem>();
                newItem.OriginalDate = DateTime.Now.Date.AddDays(-1);
                newItem.Resend = true;
                newItem.SendDate = DateTime.Now.Date;
                newItem.UserName = "TestUser";
                FileSendItem fileSendItem = fileSendItemFactory.CreateObject();
                Assert.IsNotNull(fileSendItem);
                Assert.IsTrue(fileSendItem.IsTransient);
                fileSendItem.AdditionalFileDestinations = new List<AdditionalFileDestination>();
                fileSendItem.IsFile = true;
                fileSendItem.MainFileDestination = @"C:\test";
                fileSendItem.Size = 10;
                fileSendItem.Name = "test.txt";
                AdditionalFileDestination addDest = additionalFileDestinationFactory.CreateObject();
                addDest.Destination = "D:\test";
                fileSendItem.AdditionalFileDestinations.Add(addDest);
                newItem.FileSendItems.Add(fileSendItem);
                AreaDestination areaDest = areaDestinationFactory.CreateObject();
                areaDest.Name = "TestArea";
                areaDest.Type = 1;
                newItem.AreaDestinations.Add(areaDest);
                repository.Add(newItem);
                entityModelManager.SaveChanges();
                #endregion

where repository is a wrapper around IObjectSet.
4. When I run my test it's hanging on entityModelManager.SaveChanges(). VS memory usage becomes about 400Mb and processors about 50-60%. And the only thing I can do is to kill the process... I checked csdl, ssdl and msl and everything seems to be ok. So what can couse this hang up?

And also I have another question: is it possible to use objects from different namespaces in edmx? I mean so-called C space objects