poco

Entity Framework code first: How to ignore classes

耗尽温柔 提交于 2019-11-29 17:38:22
问题 This is similar to questions here and here, but those are old and have no good answers. Let's say I have the following classes: class HairCutStyle { public int ID { get; set; } public string Name { get; set; } } class CustomerHairCutPreference { public int ID { get; set; } public Customer Customer { get; set; } public HairCutStyle HairCutStyle { get; set; } } Let's say my HairCutStyle data is stored in a table in another database (I get it from Paul Mitchell himself). I want to use the

Why is “Fixup” needed for Persistence Ignorant POCO's in EF 4?

▼魔方 西西 提交于 2019-11-29 17:08:21
问题 One of the much-anticipated features of Entity Framework 4 is the ability to use POCO (Plain Old CLR Objects) in a Persistence Ignorant manner (i.e. they don't "know" that they are being persisted with Entity Framework vs. some other mechanism). I'm trying to wrap my head around why it's necessary to perform association fixups and use FixupCollection in my "plain" business object. That requirement seems to imply that the business object can't be completely ignorant of the persistence

“Metadata information not found” while using EF4's POCO Template?

筅森魡賤 提交于 2019-11-29 16:17:18
问题 I just installed the POCO Template for EF4. I have a single entity in my model, AnnouncementText , and the T4 files seem to be properly generated. Attempting to access this new entity is throwing the following error when I access the auto-generated property MyObjectContext.AnnouncementTexts : InvalidOperationException: Mapping and metadata information could not be found for EntityType 'MyNamespace.AnnouncementText'. The properties on the AnnouncementText POCO seem to match up with the columns

Copying NHibernate POCO to DTO without triggering lazy load or eager load

空扰寡人 提交于 2019-11-29 14:59:13
I need to create DTOs from NHibernate POCO objects. The problem is that the POCO objects contain dynamic proxies , which should not be copied to the DTO. I eager load all the collections and references I need to transfer in advance, I don't want NHibernate to start loading referenced collections which I did not load in advance. Several similar questions on SO received answers which either: Suggest Session.GetSessionImplementation().PersistenceContext.Unproxy(); Suggest turning off Lazy Loading. In my case the first suggestion is irrelevant, as according to my understanding it causes eager

Add property to POCO class at runtime

不打扰是莪最后的温柔 提交于 2019-11-29 10:08:41
I selected ServiceStack OrmLite for my project which is a pure Data-Oriented application. I am willing to allow the end user to create his own Object Types defined in an XML format that will be used to generate classes at runtime using CodeDOM . I will be also defining some "system" objects required by the application (i.e. User ) but I cannot foresee all the properties the end user will use and therefore I am looking for a way to allow extending the classes I create in design time. Sample bellow public class User { public Guid Uid { get; set; } public String Username { get; set; } public

How should I structure a simple ASP.NET MVC app?

大憨熊 提交于 2019-11-29 08:26:19
问题 I've been reading a few things about ASP.NET MVC, SOLID and so on, and I am trying to figure out a simple "recipe" for small-to-medium ASP.NET MVC apps that would put these concepts together; the issue that I am most concerned with is ending up with controllers that are too complex and being like code-behind files in webforms, with all type of business logic into them. I am considering the following architecture, for a small data-driven app: Controllers: only handle requests, call an

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

假如想象 提交于 2019-11-29 04:53:22
问题 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 were detected during model generation: \tSystem.Data.Entity.Edm.EdmAssociationConstraint: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical. There is no InnerException available for any

How would I know if I should use Self-Tracking Entities or DTOs/POCOs?

心不动则不痛 提交于 2019-11-29 03:25:24
问题 What are some questions I can ask myself about our design to identify if we should use DTOs or Self-Tracking Entities in our application? Here's some things I know of to take into consideration: We have a standard n-tier application with a WPF/MVVM client, WCF server, and MS SQL Database. Users can define their own interface, so the data needed from the WCF service changes based on what interface the user has defined for themselves Models are used on both the client-side and server-side for

Domain Entities, DTO, and View Models

孤街浪徒 提交于 2019-11-29 02:27:14
问题 I have an ASP.NET MVC 2 application with a POCO domain model and an NHibernate repository layer. My domain model has no awareness of my viewmodels so I use automapper to go from viewmodel to entity and vice/versa. When I introduced WCF to my project (a late requirement), I started having to deal with disconnected objects. That is, I retrieve an entity from the database with NHibernate and once that entity is serialized it becomes disconnected and each child collection is loaded regardless of

Entity Framework POCO SaveChanges() on Update doesn't work?

泄露秘密 提交于 2019-11-28 23:32:20
I'm working with EF CTP 4, using POCO models, adding a new object and call SaveChanges() works but updating the object doesn't work. Here's the code for update: public void UpdateContact(Contact contact) { var findContact = GetContact(contact.ContactID); findContact = contact; _context.SaveChanges(); } public Contact GetContact(int contactId) { return GetAllContacts().SingleOrDefault(c => c.ContactID == contactId); } public IQueryable<Contact> GetAllContacts() { return _context.Contacts; } I'm not sure what I'm doing wrong here. Any idea? Thanks. The problem is that when you assign findContact