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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

WCF and Entity Framework Design question

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :WCF
Should we be using Entity Framework entities as data contracts across the WCF Layer? If yes when why have the POCO support and code only been added to the Entity Framework? I was assuming it was with the purpose to remove the dependancy that the client will have on the database if the client depends on the Entities. If No, then does that mean we need to create Business Objects for each entity that exists in the entity framework model? Please advise. Thanks.Nilotpal

View Complete Post

More Related Resource Links

Entity framework simple question




First I am newbie using EF - so sorry on this basic question


I have a Project Table that relate to Company Table


When I Map with EF I Do not have property of CompanyId in the Project Object

But I have related Company Object


For example

Project p = new Project();

p.CompanyId è does not exist!

When I try addingit myself I get this error:

If I need just the Company id, and I don't want get it like

p.Company.CompanyId - because than the application try connect again to the DB and I don't want this, because I need just the CompanyId.

What the best regular way to get it?


Entity framework noob question

I have been struggling to understand how this works. In the image above i have these db tables generated by Entity Framework. Problem is it seems that when i use the code below to assign the location values obtained from a listbox to the division being created/edited EF creates a new location and then enters that locations id and the divisions is into the DivisionLocation table thus creating multiple locations unnecessarily, as depicted below. using (FRLEntities context = new FRLEntities()) { for (int i = 0; i < lstPicked.Items.Count; i++) { var lpn = cm.GetLocation(Convert.ToInt32(lstPicked.Items[i].Value)); Location cLocation = new Location { LocationId = Convert.ToInt32(lstPicked.Items[i].Value), LocationName = lstPicked.Items[i].Text, LocationParentName = lpn.LocationParentName }; //CurrentDivision.Location = new EntityCollection<Location>(); CurrentDivision.Location.Add(cLocation); } } Division Divisionid            DevisionName 1                            1st Division 2    &nb

Entity Framework Inheritance Question



I have two tables in my EDMX, I'll call them table A and table B.  I would like for table B to be inherited from table A, so A is the base type and B is derived from A.  I have set this up in my EDMX file as such by removing the association between the two tables, adding the inheritance and deleting the duplicate columns in B.  All fields are mapped properly and I have mapped the insert/update commands to stored procedures.  When I run run a test to save changes to B, I get no errors.  However, none of the fields in my base table, table A, are updated.  And when I try an insert, I get an error saying there is a foreign key violation.  When I checked with SQL profiler, I found that only the stored procedure to insert into table B is called.  I would need for the insert to table A to happen first, then table B.  But this is not happening and my update is not even touching table A.  Is there anything special I need to do to make sure that both tables are updated properly and the inserts are done for both (and in the correct order)?

Any tips would be greatly appreciated.


Cannot drag an Entity Framework Data Source (created in a separate solution) onto WPF Design Surface


I receive the error Cannot add the control to the design surface or bind to the contol because the type Pec.CustomerEntity.Carrier, Pec.CustomerEntity,Version=, Culture=neutral, PublicKeyToken=null cannot be resolved.  Please try to build the project or add necessary assembly references  (I have rebuilt and it still doesn't work)   -  when I try to drag the data source onto the window. 

If I create an entity framework project within the wpf application solution and create a data source and reference to it, it works fine when I drag the data source onto the window.  I only get the error when I create a reference to an EF project .dll created outside of the wpf project.  I am using Visual Basic 2010.    I have also tried adding the project to the wpf solution and it still gives me the error. 

Question on deleteObject in the Entity framework


I want to delete a record from a table, but I want to save the data in a deleted table (as in a table to hold deleted records) first.  I also need to change a field in the first table's parent.  So I find the record I'm looking for in the first table, then I see if it already exists in the deleted table.  Then I either create or update the deleted table record.  I update the field in the parent, call deleteObject on the record I want to delete, then save the changes.  Everything is working except the record I want to delete isn't getting deleted.  Here's my code:

Dim e = (From employ In context.prResumes
              Where employ.fileNum = sFile
              Select employ).FirstOrDefault
Dim d = (From delEmploy In context.delprResumes
              Where delEmploy.fileNum = sFile
              Select delEmploy).FirstOrDefault
If d Is Nothing Then
    .... create the record here ....
    e.Person.employment = False

Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.

Entity Framework 4 Tips for WinForms Development

I've been recently working on a smart client (WinForms) application backed by Entitiy Framework 4 (EF4) on Visual Studio 2010. In this blog post I will try to give you some tips regarding some limitations and points to be careful about EF4.

database interface design question


For handy database interface, is it good to use SqldataSources exclusively intead of EntLib functions?

Thanks for any feedback.

Data accessors or Entity framework


The entlib 5 sugest me to use with data accessors for mapping data from database to my data objects (ORM).

But in .NET 3.5 and especially in .NET 4, I can use in entity framework as ORM methodology for data objects.

What data accessors uses advantages over the entity framework?

What differences that should be affect on my using decisions?

Data Points: Deny Table Access to the Entity Framework Without Causing a Mutiny


Julie Lerman shows database administrators how to limit access to databases from the Entity Framework by allowing it to work only with views and stored procedures instead of tables-without impacting application code or alienating developers.

Julie Lerman

MSDN Magazine August 2010

VS 2010: Entity Framework 4.0 and WCF Data Services 4.0 in Visual Studio 2010


Elisa Flasko takes you through a sample weblog application to demonstrate how new improvements in Entity Framework and WCF Data Services work together to simplify the way data is modeled, consumed and produced in Visual Studio 2010.

Elisa Flasko

MSDN Magazine April 2010

N-Tier Apps and the Entity Framework: Building N-Tier Apps with EF4


This article is the third in a series about n-tier programming with the Entity Framework, specifically about building custom Web services with the Entity Framework and WCF. This article looks at features coming in the second release of the Entity Framework (EF4) and how you use them to implement the Self-Tracking Entities and Data Transfer Objects (DTOs) n-tier patterns.

Daniel Simmons

MSDN Magazine November 2009

Entity Framework: N-Tier Application Patterns


This article examines n-tier patterns for success and some of the key APIs and issues specific to the Entity Framework. It also provides a sneak peak at features coming in the Microsoft .NET Framework 4 that should make n-tier development significantly easier.

Daniel Simmons

MSDN Magazine August 2009

Entity Framework: Anti-Patterns To Avoid In N-Tier Applications


Danny Simmons explores some anti-patterns you should look out for when building n-tier applications with the Entity Framework.

Daniel Simmons

MSDN Magazine June 2009

SOA Data Access: Flexible Data Access With LINQ To SQL And The Entity Framework


Building a data access layer using LINQ to SQL and the ADO.NET Entity Framework allows you to decouple your application from the persistence technology you're using.

Anthony Sneed

MSDN Magazine December 2008

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