poco

Foreign Key To Microsoft.AspNet.Identity.EntityFramework.IdentityUser?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 10:10:43
I'm in VS 2013 and have just created an MVC application. I'm creating an object I intend to have a foreign key to the AspNetUsers table in the resulting database. The project does have an ApplicationUser (deriving from IdentityUser) that looks like a property-column match with the AspNetUsers table. How do we properly declare a foreign key to this? public MyObject { public string UserId { get; set; } [ForeignKey("UserId")] public ApplicationUser User { get; set;} // other properties } Now, I modify ApplicationUser to have a collection of MyObjects: public ApplicationUser : IdentityUser {

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

岁酱吖の 提交于 2019-11-28 08:48:23
问题 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

Automapper : mapping issue with inheritance and abstract base class on collections with Entity Framework 4 Proxy Pocos

北战南征 提交于 2019-11-28 04:06:58
I am having an issue using AutoMapper (which is an excellent technology) to map a business object to a DTO where I have inheritance off of an abstract base class within a collection. Here are my objects: abstract class Payment class CashPayment : Payment class CreditCardPayment : Payment I also have an invoice object which contains a collection of payments like so: public class Invoice { ... properties... public ICollection<Payment> Payments { get; set; } } I also have corresponding DTO versions of each of these objects. The DtoInvoice object is defined as: [DataContract] public class

converting POCO entity to business entity

让人想犯罪 __ 提交于 2019-11-27 21:45:24
I am willing to integrate the entity framework as my data layer. I followed articles and generated poco entities using this tutorial: http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx I have my own business objects. Here is my business object Brach: public class Branch { public long BranchId { get; private set; } public string BranchName { get; set; } public string BranchCode { get; set; } public Branch() { } public void InsertBranch(Guid companyId) { using (var ctx = new Entities.Entities()) { var branch = new T_STF_BRANCH() //This is

EF POCO code only VS EF POCO with Entity Data Model

╄→尐↘猪︶ㄣ 提交于 2019-11-27 20:35:24
The ability to separate domain objects completely from any kind of persistance code makes systems much more extensible and maintainable. Testing is made much easier when business logic can be tested separately from storage code. The use of POCOs with the Entity Framework (EF) is definitely a step in the right direction :) there are 2 types of using poco with EF 1.Using the entity designer 2.Using the code only which one is the best approach EF poco code first or EF Poco using the entity data model designer ? thanks It is just a matter of choice. EFv4 with designer Pros: You have designer

Explanation of POCO

五迷三道 提交于 2019-11-27 20:07:02
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. RPM1984 Instead of calling them POCOs , I prefer to call them persistence ignorant objects . Because their job is simple, they don't need to care about what they are being used for or how they are being used. Personally I think POCOs are just another buzzword (like Web 2.0 - don't get me started on that) for a public class with simple properties. I've always been using these type of objects to hold onto

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

南笙酒味 提交于 2019-11-27 18:09:24
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 DbContext ) and start each controller action with using(var unitOfWork = new UnitOfWork()) { ... } Share your experience please: Which one would you prefer? what are pros and cons for each approach? I would suggest you use a Dependency Injection framework. You can register your DbContext as per request container.RegisterType<MyDbContext>()

What does POCO mean? [duplicate]

China☆狼群 提交于 2019-11-27 18:04:48
This question already has an answer here: 'POCO' definition 10 answers I have seen many articles about POCO. What is this? Plain old CLR object balexandre Based in the language you want to choose POCO means Plain Old CLR Object as Wikipedia mention or, Plain Old C++ Object as the PocoCapsule mentions it or, POrtable COmponents as the POCO Project mentions it. For what I'm concerned and for the reason of this question, and of course in simple words, it's a C++ library . :) The POCO C++ Libraries aim to be for network-centric, cross-platform C++ software development what Apple's Cocoa is for Mac

What is POCO in Entity Framework? [closed]

守給你的承諾、 提交于 2019-11-27 17:39:34
I just started learning POCO but cannot understand its use and advantage. Even following link of stackoverflow did not help me. what is Entity Framework with POCO Can anybody explain the usage of POCO with a simple example? Prabhu Murthy POCOs(Plain old CLR objects) are simply entities of your Domain. Normally when we use entity framework the entities are generated automatically for you. This is great but unfortunately these entities are interspersed with database access functionality which is clearly against the SOC (Separation of concern). POCOs are simple entities without any data access

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

可紊 提交于 2019-11-27 17:24:31
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 requires two different diagrams to access the data. The EF diagram data context is the "Unit of Work", having a single Save() for anything on the diagram. (Sure you could wrap it in a UnitOfWork class, but it essentially has the same duties). Assuming that's correct, here