Questions tagged [poco]

Means Plain Old CLR Object, a simple object that does not follow any object model, convention or framework. For questions about the POCO C++ library, please use [poco-libraries].

Means Plain Old CLR Object, a simple object that does not follow any object model, convention or framework. For questions about the POCO C++ library (http://pocoproject.org), please use [poco-libraries].

1553 questions
35
votes
4 answers

what is Entity Framework with POCO

What is the benefit of using POCO? I don't understand the meaning of Persistence Ignorance, what does this mean? That the poco object can't expose things like Save? I can't wrap my head around this POCO that there's alot of buzz around. What is the…
pdiddy
  • 6,217
  • 10
  • 50
  • 111
35
votes
3 answers

How to fix: The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical?

I am using Entity Framework 4.3.1 against a SQL Server 2012 database and I am using the POCO approach. I am getting the following error and I am wondering if anyone can explain how to fix it: ModelValidationException One or more validation errors…
kmp
  • 10,535
  • 11
  • 75
  • 125
34
votes
4 answers

Exclude a field/property from the database with Entity Framework 4 & Code-First

I will like to know that is there a way to exclude some fields from the database? For eg: public class Employee { public int Id { get; set; } public string Name { get; set; } public string FatherName { get; set; } public bool IsMale…
Yogesh
  • 14,498
  • 6
  • 44
  • 69
33
votes
1 answer

Why does DbSet.Add work so slow?

The same topic was discussed here 8 months ago: How do I speed up DbSet.Add()?. There was no solution proposed other than using SqlBulkCopy which is not acceptable for us. I've decided to bring it up once again hoping there might be new thoughts and…
YMC
  • 4,925
  • 7
  • 53
  • 83
32
votes
3 answers

Explanation of POCO

I'm wondering if anyone can give a solid explanation (with example) of POCO (Plain Old CLR Object). I found a brief explanation on Wikipedia but it really doesn't give a solid explanation.
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
31
votes
4 answers

Self Tracking Entities vs POCO Entities

We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services.…
Kumar
  • 2,863
  • 11
  • 45
  • 60
30
votes
3 answers

What is the best way to instantiate and dispose DbContext in MVC?

MVC 3 + EF 4.1 I'm choosing between two approaches to deal with DbContext: Instantiate in Application_BeginRequest, put it into HttpContext.Current.Items and dispose in Application_EndRequest. Create disposable UnitOfWork (kindof wrapper for…
YMC
  • 4,925
  • 7
  • 53
  • 83
29
votes
1 answer

EF CTP5 - Strongly-Typed Eager Loading - How to Include Nested Navigational Properties?

Attempting to cutover our EF4 solution to EF CTP5, and ran into a problem. Here's the relevant portion of the model: The pertinent relationship: - A single County has many Cities - A single City has a single State Now, i want to perform the…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
28
votes
4 answers

How to serialize/deserialize simple classes to XML and back

Sometimes I want to emulate stored data of my classes without setting up a round trip to the database. For example, let's say I have the following classes: public class ShoppingCart { public List Items {get; set;} public int…
Ben McCormack
  • 32,086
  • 48
  • 148
  • 223
27
votes
2 answers

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…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
26
votes
4 answers

What is the best practice for sending data to the client: POCO or DTO?

I'm starting a project using EF 4 and POCO. What is the best practice for sending data to the client ? Should I send the POCO or I should have a DTO instead? Are there any issue I should be aware of when sending the entity (that is disconnected…
pdiddy
  • 6,217
  • 10
  • 50
  • 111
26
votes
11 answers

ORM/Persistence layer Advice

I'm starting a new project and I'm looking around for either a very good ORM or for a non-SQL-based persistence layer. For this project, I really don't care on how the data is persisted, as long as it can be queried and stored with a reasonable…
em70
  • 6,088
  • 6
  • 48
  • 80
25
votes
1 answer

What is the proper data annotation to format my decimal property?

I have a POCO with a decimal property called SizeUS. I would like to use data annotations to format the display of the decimal in a view. My SizeUS property is only displaying 2 decimal places in my view and I want it to display 4 decimal places. …
Bill Greer
  • 3,046
  • 9
  • 49
  • 80
24
votes
0 answers

Known reasons why sqlite3_open_v2 can take over 60s on windows?

I will start with TL;DR version as this may be enough for some of you: We are trying to investigate an issue that we see in diagnostic data of our C++ product. The issue was pinpointed to be caused by timeout on sqlite3_open_v2 which supposedly…
Yester
  • 652
  • 6
  • 18
24
votes
2 answers

Custom setter for C# model

I don't know how to make custom setter for C# data model. The scenario is pretty simple, I want my password to be automatically encrypted with SHA256 function. SHA256 function works very well (I've used in in gazillion of projects before). I've…
Stan
  • 25,744
  • 53
  • 164
  • 242