.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Northwind POCO

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
You cannot vote on your own post

I am trying to create a POCO with EF4 for Northwind db. I am running into problem where the table name Order Details has a space.
If i create a POCO Class OrderDetails it throws exception saying  System.Data.SqlClient.SqlException: Invalid object name 'dbo.OrderDetails'.

public class OrderDetail

    public int OrderID { get; set; }

    public Order Order { get; set; }

    public Product Product { get; set; }

    public double UnitPrice { get; set; }

    public int Quantity { get; set; }

    public int Discount { get; set; }


View Complete Post

More Related Resource Links

Dynamic Data, Domain datasource, Poco and lookups


Mr. Edward,

Excuse my question but: it is necessary to involve in our projects something more than just Dynamic Data or should we make use of all other features available in VS2010 (which will make assume taht they had been left out of the Dynamic Data framework) like: wef, poco, azure, wcf, cloud, mvc, silverllight, ajax, odata, agile, workflow, etc.?

Sorry my ignorance, I'm just transcribing names as they come to my mind and of which I don't know anything about


Carlos Porras (El Salvador)

Problem insert POCO to Velocity Cache



I want to put POCO object to Velocity cache. How can I serializable ICollection to Velocity cache, or exclude ICollection from serialization?

I got this exception

Type 'System.Collections.Generic.ICollection`1[Model.Collection]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.



Master/Detail with Northwind (SSMA) and ASP.NET

I'm trying this example: http://www.asp.net/data-access/tutorials/master-detail-filtering-with-a-dropdownlist-cs I got it to work before, like 6-months ago.  I'm coming back to this now and I can't seem to get the example working. Do I need to create a query in SSMS and then set up my Master/Detail views off of that?  It seems like the GridView is NOT linked to the DropDownList and it seems like there is no way to link the two Objects.  Any ideas as to what I could be doing wrong? Thanks everyone!!

WF Service using EF4 POCO Entities Issue

Hi I've a WF Service using my EDMX and my Classes generated using a poco t4 template, but on execution when i include navigation properties related to a 1 to many or many to many relationships i got an underlying connection was closed error. I've traced the error and i got 2 exceptions different exceptions depending on which parameters i pass to my context and my ReciveAndSendReply Action. One is the related to that Navigation Property and the fact that it is generating a cyclic reference A.B  B.List<A> or viceversa and cant be serialized. The other changing my context property to enabling/disabling the proxy creation i get a overflow on the max message size or max message on the trace (the cyclic reference is doing an overflow and the entity back from the WF service is not coming back. Hope you can help me guys to figure out whats going on. Thx Pedro

CommunicationException when serializing my business POCO object

Hi! I'm currently blocked by a strange problem, here is the situation: I've a client and a server, running with .Net 4.0 framework. I'm using Entity Framework server side, and WCF to communicate between client and Server. I use POCO object on my Entity Framework model. One month ago, I had a problem: In some case entity framework has already loaded an object and then want to return it when the WCF service is queried. Example: An User has a collection of Orders, and Orders knows which User handle it---> cyclic references I searched online how to resolve this and I found this: http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html It worked like a charmed for me until now. I can get data from the server without server, ... Now I'm trying to call my Save(User) method from the client to the server, and I get this error:   System.ServiceModel.CommunicationException was caught Message=There was an error while trying to serialize parameter http://tempuri.org/:User. The InnerException message was 'Type 'System.DelegateSerializationHolder+DelegateEntry' with data contract name 'DelegateSerializationHolder.DelegateEntry:http://schemas.datacontract.org/2004/07/System' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribu

Entity Framework POCO and WCF Data Service - Lazy-loading (expand?) related entities?

I've followed ScottGu article on creating an Entity Framework POCO classes for NerdDinners (right now there are only 2 classes, Dinner and RSVP. I then created a WCF Data Service class, which points to my EF class (NerdDinner), everything is working fine, except I can't lazy-load or expand related entities. For example, I want to get all load all the Dinners and their related RSVPs, something like this throw an error:var result = (from d in db.Dinners.Expand("RSVPs")                      select d);The error is a null reference error:at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot) at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri absoluteUri, String relativeUri, SyndicationItem target) ... ... ...Any idea why or what I need to do to load related contents?Thank you very much.

Wanted northwind sql server 2008 samples


Hi i m looking for northwind 2008 sample database. But i m unable to get the link. All links are for 2000 samples. Please help

Try to connect Northwind database.


Hi I have Northwind database for access, Nwind.mdb.

The default user is "Admin", it is inconvient for me while I debug code. I always got login user failed error. How can I deal with it? Change user?

 Private NorthwindConnection As New SqlConnection _
  ("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Nwind.mdb;Initial Catalog=Northwind;Integrated Security=True")


EF4 Poco list.Clear()



In nHibernate this works perfect, you have a Entity with a list of something. If you do list.Clear() on that list the entities in that list will be Deleted from DB.

If i do the same in EF4 with Poco entities i get a constraint error, is it possibel to get this behavoir out of EF?

How to implement DAL for Cross Tables (e.g. Northwind Orders & OrderDetails)


Microsoft has two very helpful articles on DAL (Creating a Data Access Layer) &

BLL (Creating a Business Logic Layer) but they are Incomplete as the does not cover all the Tables.

The most Important tables in Northwind db are Orders & OrderDetails. Both the articles have nothing about them.

Can any one provide any info. on them ?

Windows 7 x64, SQL Express 2008 - Problems attach Northwind database

I've attached Northwind many times before, but seem to be unable to do so in Windows 7. I tried attaching from Visual Studio, using osql, and finally (after many hours) installed SQL Express 2008 / SQL Management Express 2008. All methods failed. The last failure (using SME 2008 Attach Databases) is sometimes:

Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\northwnd.mdf". Operating system error 2: "2(failed to retrieve text for this error. Reason: 15105)". (.Net SqlClient Data Provider)

and other times:

Database 'Northwind' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery. (Microsoft SQL Server, Error: 3415)

I have, of course, verified countless times that the files are NOT read-only.

Could any please explain what could be happening here? All suggestions much appreciated.

many thanks,


What's the point of serialising a POCO proxy when using WCF?


I'm quite new to WCF, and am trying to get to grips with it. I'm using the Entity Framework (Visual Studio 2010 Professional, .NET v4), and have been reading about using POCOs instead of sending EntityObject derived stuff across the wire.

It seems that WCF can't serialise the POCO proxies, so you either have to switch them off, or add code to serialise them. I found an MSDN article http://msdn.microsoft.com/en-us/library/ee705457.aspx that shows how to do this, as well as http://msdn.microsoft.com/en-us/library/dd456853.aspx and http://msdn.microsoft.com/en-us/library/ee705457.aspx amongst others.

All in all, it seems that serialising POCO proxies is a standard thing to do. What I can't understand is why you would want to do this? From my brief, but fairly in-depth study of WCF, it seems to be a data service, and does not send anything but data across the wire. If so, surely the proxies are useless as they won't manage the change tracking?

Have I got this completely wrong? I can't see what benefit you would get by serialising a proxy. Isn't that the whole point of self-tracking entities?

I would be grateful if someone can enlighten me, 'cos I'm confused!

If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at

Not able to attach or restore northwind.mdf and northwind.ldf files



I downloaded nothwind.mdf and nothwind.ldf  files from the net.when I try to attach any of these files, i am getting the error as "Unable to open the physical file "d:\northwind.mdf".Operating system error5. 5 Access is denied.

Can you please help me to resolve this issue?

How do I update with EF4 + T4 POCO on MVC 2


Hi, I search through the web and I couldn't find a way to update with T4 POCO.

Here is my code works fine with Entity Framework:

        public void UpdateProduct(Product product)
            var res = (from r in _context.Products
                       where r.ProductID == product.ProductID
                       select r).FirstOrDefault();
            _context.ApplyPropertyChanges(res.EntityKey.EntitySetName, product);

How do I change this to T4 POCO?

Editing a poco's navigation property without the data context



I am using EF 4.

I need to set a navigation property. I could do something like this:

using (MyDataContext context = new MyDataContext())
    affaire.QualityID = 2;

The problem is that I want to do this in the code behind and I don't have any DataContext.
The logic for using a POCO would be just doing this:
affaire.QualityID = 2;
affaire.Quality = quality;

And later let the Bll load a context, attach the poco and save the changes. But I get an error message:
"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection"
Is there any way for doing this scenario?

WCF - Entity Framework - POCO - Caching with multiple services



We have an architecture where we use Entity Framework with POCO, and the code-first approach (no edmx file). In order to explain the problem I have to explain a little bit about our architecture:

We have one layer which contains Routing Services (for load balancing and security), and a layer of Data Access Services. All services are hosted in IIS.

What we would like is to have caching of our (Entity Framework) Context, so we made the context static, and thought it would be shared between the different services. Well, it's not... 

The scenario (where we noticed the problem) was that we did some changes to an transaction through the Transaction services. We then did a search through the Search services, and found that the data wasn't updated. Well, actually the data are updated, and saved to the DB, it's just that the "Search Context" is out of sync. When retrieving the data from the Transaction service, we got the correct data, as expected.

So, after hours of googling I still haven't found a solution to the problem, and I'm hoping to get some response here.

WPF POCO Validation Question


Hi all,

I am building a WPF 4 application with Prism and MVVM, I have some POCO to bind with different views in different modules. I would like to implement validation of user input.

After I have done tons of search I found all of the implmenetations are based on property changed and validation logic kicking off right away. And typical way is to leverage attributes under System.ComponentModel.DataAnnotations namespace and IDataErrorInfo interface.

My requirements are:

  • I don't want object to be validated until I click on some button. If I call Validator.TryValidateObject from my event handler, it does not seem that UI control can be notified with the errors.
  • I need different validation rules agaisnt same object in different modules/views. For example a field in module A is optional; but mandatory in module B.

Anybody has some good suggestion, articles to describe my requirements?



Welcome to help me with my open source project at http://code.google.com/p/batch-image-watermark-processor/
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend