poco

Using EF POCO classes as MVC 2 models (with data annotations)

I have a 4 layered web application programmed in C#... .Net 4.0: UI Layer Business Layer Data access Layer Entities layer My data layer contains an edmx My entities layer contains my POCO objects (generated by a t4 script), and that layer is referenced in all other layers. When creating an MVC form to create a new customer, for exam...

Efficiently Determine if EF 4 POCO Already in ObjectSet

I'm trying EF 4 with POCO's on a small project for the first time. In my Repository implementation, I want to provide a method AddOrUpdate that will add a passed-in POCO to the repository if it's new, else do nothing (as the updated POCO will be saved when SaveChanges is called). My first thought was to do this: public void AddOrUpdat...

EF 4, POCO and AddOrUpdate

I'm trying to create a method on an EF 4 POCO repository called AddOrUpdate. The idea is that the business layer can pass in a POCO object and the persistence framework will add the object if it is new (not yet in the database), else will update the database (once SaveChanges() is called) with the new value. This is similar to some oth...

EFv1 mapping 1 to many Relationship to POCOs

I'm trying to work through a problem where I'm mapping EF Entities to POCO which serve as DTO. I have two tables within my database, say Products and Categories. A Product belongs to one category and one category may contain many Products. My EF entities are named efProduct and efCategory. Within each entity there is the proper Navigat...

Portable C++ library for IPC (processes and shared memory), Boost vs ACE vs Poco?

Hi, I need a portable C++ library for doing IPC. I used fork() and SysV shared memory until now but this limits me to Linux/Unix. I found out that there are 3 major C++ libraries that offer a portable solution (including Windows and Mac OS X). I really like Boost, and would like to use it but I need processes and it seems like that this...

Entity Framework 4 Code First and the new() Operator

I have a rather deep hierarchy of objects that I'm trying to persist with Entity Framework 4, POCO, PI (Persistence Ignorance) and Code First. Suddenly things started working pretty well when it dawned on me to not use the new() operator. As originally written, the objects frequently use new() to create child objects. Instead I'm usin...

What causes POCO proxy entities to only sometimes be created in Entity Framework 4.

I have set up my POCOs and I have marked their public properties as virtual and I am successfully getting Proxies most of the time (95%) but randomly I am getting EF return some proxies and some non-proxies. Recycling the app pool when this happens will then fix this instance of the error and it will go away for an amount of time. Then ...

What am I doing wrong?

First I come from a nettiers background. And I really think that is getting in the way of trying to figure out how to use EF4. Second. I am using the POCO templates available from MS. I have lazy loading enabled as well as proxy generation. in my application I am eagerloading an selected doctors information from my users selection: do...

EntityFramework 4.0 POCO Namespacing issue

I'm playing around with the EF 4.0 POCO CTP (from here). I'm constructing an ObjectContext using the ContextBuilder class like so context = new ContextBuilder<T>().Create(new SqlConnection(...)); T is of type ObjectContext. When I try to get a reference to all the mapped entities in the context like so: var entities = context.Met...

EF 4.0 Dynamic Proxies POCO Object Does not match target type.

I am using EF 4.0 and POCO's. I stumbled across this error while inserting to records into the data base. Property accessor 'QualityReasonID' on object 'BI.Entities.QualityReason' threw the following exception:'Object does not match target type.' There errors occur on the Databind to a GridView after saving a new record to the databas...

When should POCO be used in EF4?

We have an ASP.Net MVC2 web site, and are utilizing EF4 for database access, etc. Being new to EF4, we have come across the EF4 POCO concept, however do not fully understand it. In general, I've heard POCO defined as objects "not dependent on an external framework". In the case of EF4, I'm guessing this means that POCO would imply som...

Entity Framework Code Only Relationship Not Being Read

(This looks like a long question, but it's not really, honest!) I am trying to get a simple proof of concept working with Entity Framework 4 and the CTP 3 version of Code Only. It feels like I'm missing something really obvious and simple. I have this following test which is failing: [TestFixture] public class ParentChildTests { [...

DataServieException: Oracle, EFOracleProvider, POCO and EF 4.0

I try to use the new POCO capabilities of EF 4.0 in combination with the EFOracleProvider. I have recompiled the EFOracleProvider (using ODAC instead of System.Data.OracleClient) to target the .NET Framework 4 (und put it in the 4.0 GAC). Everything ok so far. I host the Entity Model in a WCF Data Service: class DivaDispoDataService : ...

Function Import and Repository pattern with Entity Framework 4.0

Could anyone advise me on how they've implemented the use of Function Imports when using the Repository pattern against EF 4.0? We have a table mapped to a Candidate Entity and also a Function Import off an existing sproc that maps to Candidate. This works great in EF but we're abstracting by use of Repositories which take on their con...

Is this a proper way to use POCOs?

Function DeepLoadDoctors(ByVal doc As Doctor) As Doctor Implements IDoctorsService.DeepLoadDoctors Using _context As New referee2Entities doc = _context.Doctors. Include("DoctorLicense"). Include("DoctorHome"). Include("DoctorHome.ContactInfoes"). ...

Many-To-Many Relationship in Code-First EF4

How do you represent a many-to-many relationship in the EF4 Code-First CTP3? For example if I have the following classes: class User { public int Id { get; set; } public string Name { get; set; } public ICollection<Profile> Profiles { get; set; } } class Profile { public int Id { get; set; } public string Name { ge...

Where can I find (near) samples for different layers involved here

I am trying to implement a prototype based on the following: http://apparch.codeplex.com/wikipage?title=App%20Pattern%20-%20Three-Tier%20RIA%20Application%20Scenario While I understand most of it, I am just wondering if I could learn more from an existing samples regarding various layers as shown above. thanks. ...

Is it possible to use EF 4.0 without having a dependence on .NET 4.0

Lets say I build an Service Layer wich deals with POCOs coming out of an repository. The Repository is aware of the EF 4.0 and deals with POCO generation and so on. But that does also mean that my Repository will have a .NET 4.0 dependency and so my Service Layer which consumes the Repository will also have a .NET 4.0 dependency...even i...

Pros and Cons of POCO / Autogenerating Database Tables

Hi, I've just been assigned to a ORM mapping project (data-centric app with C# code and SQL Server database) for which the requirement is explicitly that POCO will be used, and that the ORM will autogenerate the database from the C# objects - so the C# object model is in effect king of the data. I'd not heard of POCO before and I'm inst...

Entity Framework 4 column conversions - SQL Server - SQLite

I have a SQL Server database and Entity Framework Model setup with POCO objects, this is working fine. However, I have also created a Sqlite database from the SQL Server database (using a simple conversion process). So I have created another EDMX file for the SQLite database, which I would like to use my existing POCOs generated from t...