poco

Custom serialization/deserialization over a field with Entity Framework 4

Hi all, I'm in charge to migrate our own DAL to a solution based on Entity Framework 4 but, before I can do it, I need to be sure it's possible to translate all our "constructs" to this new technology. One of the biggest issues I'm having is the possibility to read a field and build a custom type. Valid examples could be a bit mask sav...

The place of Entity framework 4.0 + POCO + WCF in DDD "world".

I'm trying to get to light. In DDD approach we have Presentation Layer(UI), Application Layer(Application Services), Domain Layer and Infrastructure. I'm sure that anyone knows o short description on those 4 layers. I know WCF feet in Application Layer(Application Services), and the Entity Framework .edmx model in Infrastructure Layer....

Entity Framework POCO - Refresh a natvigation property

I am having some trouble with refreshing the related collection of entities. Essentially the problem is as follows: public class Student { public virtual ICollection<Lecture> Lectures { get; set; } public void AddLecture(Lecture lecture) { Lectures.Add(lecture); } public void CancelChanges() { ...

Business logic in Entity Framework POCOs using partial classes?

I have business logic that could either sit in a business logic/service layer or be added to new members of an extended domain class (EF T4 generated POCO) that exploits the partial class feature. So I could have: a) bool OrderBusiness.OrderCanBeCancelledOnline(Order order) .. or (IOrder order) or b) bool order.CanBeCancelledOnline(...

Creating own POCO classes wont work. ERROR Schema specified is not valid

When I try to create my own POCO classes I get this error. This is only when I got a list of some kind or acsosiation like in this case the Author got Books. But it works great when I use the T4. I kinda like to create my own classes because then I could add my AddBook() to it.. so I highly appreciate if anybody know why.. Schema speci...

Entity Framework 4: Does it make sense to create a single diagram for all entities?

I wrote a few assumptions regarding Entity Framework, then a few questions (so please correct where I am wrong). I am trying to use POCOs with EF 4. My assumptions: Only one data context can exist for an EF diagram. Data Contexts can refer to more than one entity. If you have two data sources, say MS SQL server and Oracle, EF require...

Advice on POCO Validation with ASP.NET MVC/Entity Framework

Hi Guys, Here's the scenario: ASP.NET MVC2 Web Application Entity Framework 4 (Pure POCO's, Custom Data Context) Repository Pattern Unit of Work Pattern Dependency Injection Service Layer mediating Controller -> Repository So basically, all the cool stuff. :) Flow of events for a basic UI operation ("Adding a Post"): Controller c...

EF CTP4 lazy loading not playing ball

I'm using the CTP4 code first EF framework, but I'm having problems getting lazy loading to work. Reading up on it, it should be simple, but it's just not public class Folder { public int Id { get; set; } public string Name { get; set; } public int? ParentFolderId { get; set; } public virtual IList<Folder> ChildFolders...

EF 4: Problems understanding DetectChanges when using POCO (no self tracking ObjectContext)

Hi there, I wonder if anyone can help me? I am having problems understanding why i need to issues DetectChanges on my POCO (non proxy) entities. Of course i have this line to ensure that proxies are not returned. context.ObjectStateManager.GetObjectStateEntry(order).State And doing some research it appears if i need to check the...

Where is the best place to put validation logic given this application design?

Consider an ASP.NET MVC 2 web application project that uses EF4 POCO entities and the repository pattern to store information in a SQL Server database. So far there are 3 projects, 4 if you count the database: 1.) Domain.dll, has no dependencies, exposes POCO's and repository interfaces. 2.) Storage.dll, depends on Domain, implements ...

How to auto-update the Modified property on a Entity in Entity Framework 4 when saving?

Im using EF4 in VS2010, POCO's and the model-first approach. My entity has the following properties: Id:Guid, Name:String, Created:DateTime, Modified:DateTime, Revision:Int32. I create my entity, set the name and save it to the database using the EF4-context. This should set Id to a new Guid (works with Identity-SGP), Created set to no...

EF 4.0 POCO magic doesn't work-- No changes detected.

I can't seem to update my database from disconnected poco objects. In this example, I fetch an ApplicationUser object, update varchar(100) field SSOID, but no changes take effect. Even when I refetch the object in the save method, nothing gets sent to the db. If I try to call ApplyCurrentValues, it throws An object with a key that m...

How to Clone POCO entity and add to context

I am using EF4 and I have create POCO objects with proxies from my database structure . I have a POCO (object) which has lots of relationships to other entities. I created a deep copy of the object using DataContractSerializer and BinaryFormatter and lets call it clonedObject. function used for cloning is: public T CloneProxy<T>(T sou...

Entities Framework 4 Code First: Business Methods

Could anyone tell me where is the best place to put my business methods when using EF4 code first POCOs? Should they go in the POCO class? E.g. public class customer public property Id as int32 public property Name as string public property Archived as boolean public sub MarkAsArchived me.Archived = true end...

Singleton object disposal

I've been doing some playing around with POCO objects and EntityFramework. Because of this I have to write my own Context and Repository(s). I would like all repositories to use the same context instance so changes are shared between them. To facilitate this I coded my Context as a Singleton. This way instead of getting a new context and...

EF4: Difference between POCO , Self Tracking Entities , POCO Proxies

Hi, Can someone point me the difference between POCO , Self Tracking Entities , POCO Proxies? Actually, I am working Entity Framework 4.0 and POCO(Repository Pattern) and whenever I do some changes in the POCO and call ObjectContext.Savechanges then it reflects to the DB. My question is, How does the Context persist the change to t...

Creating complex object using POCO in EF

I am trying to understand how to create a complex POCO which in the backend tied to a stored procedure or multiple tables. All the examples I have seen are simple one table to one entity or two tables. Could some one point me to a link or example on how to create a complex POCO which talks to stored procedure or multiple table. Or is it ...

Layered Architecture in Entity Framework 4.0

Hi I am trying architect a small project. I planning to have Data acess, Business Service, WcfService, UI Layer. I am trying to use EF 4.0 and MVC 2.0. My question is where to generate the entities and ObjectContext through EF. I initially planned it in DataAccess. but to make entities available across all layer I have to reference ...

Load JSON data stream from text file into objects C#

I'm using Newtonsoft.Json.Linq and I'd like to load the data into objects (or structs) that I define and put the objects into a list or collection. Currently I'm pulling out the JSON properties with indexes to the names. filename = openFileDialog1.FileName; StreamReader re = File.OpenText(filename); JsonTextReader reader = new JsonTex...

Is it possible to use existing classes as POCOs in Entity Framework

Hi, I was able to generate pocos using POCO template from Microsoft. It works great. My question is how I could modify this or any other template to use existing objects from a different assembly, and just load data into them. The way i tried going about it, was to create POCO's using the template, and the PocoGenerator.Context to ...