ado.net-entity-data-model

Unit Testing with Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model

I'm trying to get my head around using Nunit, Ninject, MVC2 and the ADO.Net Entity Data Model. Let's say I have have a ProductsController instantiating a SqlProductsRepository class. public class ProductsRepository : IProductsRepository { public MyDbEntities _context; public ProductsRepository() { _context = new My...

EntityFramework 4.0: InvalidOperationExecption: Multiplicity constraint violated

Hi, we have recently upgraded our software to .NET 4.0 and EF 4.0 (without self-tracking entities) (former .NET 3.5 SP1). Now a new exception is raised in former working code, which we do not understand. We have an entity called Resident, and another entity called ResidentExtension, which extends the already large Resident entity with ...

Ria service generated code not support partial class

I'm using Ria service class library. This contains 2 library named RiaClasslibrary RiaClasslibrary.Web. Riaclasslibrary.Web contains ADO.NET entity data model and named BaseModel. BaseModelcontains tPage class. My problem is I'm inserting separated tPage class. This class contains 2 public property. show below public sealed partial...

LINQ queries with many-to-many tables in Entity Data Model

I'm trying to use LINQ to query the following Entity Data Model based on this db model I'd like to be able to pull a list of products based on ProductFacets.FacetTypeId. Normally, I'd use joins and this wouldn't be a problem but I don't quite understand how to query many-to-many tables under the Entity DataModel. This is an exampl...

How do i get the top 5 items in a database based on the occurence of a particluar field?

Using Ado.Net Entity framework, I am trying to get the 'top 3' items in a table based on the amount of times they appear in a table. For example: Table: basket_to_product_id | basket_id | product_id I want to see how many times product_id occurs, and would like to return the top 3 product_ids that occur the most frequently. I'm stuck...

How can I share entity models from different design surfaces in ADO.NET Entities/LINQ-to-Entities?

In my current project, I am using LINQ-to-SQL with a number of entities defined in separate design surfaces, such as: Questions Events Notes In other design surfaces, I have other entities which can be related to any of the entities above (using a dual foreign key, such as a model type id and the model id itself): Vote Favorite T...

Silverlight ADO.net entity Data Model error

I'm trying to consume a WCF Data Service in a Silverlight App using an ADO.Net Entity Data Model, however I keep running into this error: The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSuppor...

ADO.NET Entity Framework and WCF Service

I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables with foreign key relationships. How can I send these entities down to a Windows Phone 7 client? I have created a WCF Service (using WShttpbinding),with the method... public List<LocationCity> ListCities() { var dc = ObjectFactory.GetInstance...

Databind ADO.NET Entity Framework to ListBox

I'm trying to attach a ADO EF object class (Materials) to a ListBox, and have it auto-update when a new material is added to the database. In my current code below, it will show any items that are in the database before the controls datasource is set, but it will not update. I know I'm missing something elementary here. Any help is gre...

A referential integrity constraint violation occurred

Hi All, I have a entity model and on it i have a object with name Person that this object have 1 ti 1 relation with NaturalPerson and LegalPerson. therefore the Person is a abstract class and Naturalperson and LegalPerson inherited from Person, but when i try to add NaturalPerson in DAL i got this error A referential integrity constrain...

ADO.NET Entity - Help needed

Hello guys, i have 3 tables in my database and i created a entity model from database and it looks like this: what im trying to do is to bind all 3 tables to datagridview and im using a query like this var result = from t in db.Transactions from c in db.Categories from a in db.Accounts ...

LINQ query to ado.data entity model selecting more than one column in c#

ECommerceAdoEntities oContext = new ECommerceAdoEntities(); var lstnames = from c in oContext.tbl_ShippingProfile select c.Name; When I try to run a linq query against a ADO.net entity data model data source and return more than one column (c.Name,c.ID) it gives me error in C# But in VB I am able to do it. Dim adoDataE...

EF CTP4: For Code Only, no database generation needed, how much DB info is needed?

I have a database, and I have entity POCO's, and all I want to use EF for is to map between the two and keep track of changes for loading, saving, etc. I have been reading a lot of the literature (such as it is) on "Code First", and I am unclear on how much of the database information I need to supply when there is not going to be a dat...

SubSonic 3, Entity Data Model (Entity Framework) or LINQ to SQL for ASP.NET MVC development?

Having used all of them (some more than others), I am still undecided on which could be the best to use (with .NET 3.5). What are the pro's and con's of each when developing? SubSonic 3 Not enough samples/documentation (I know its a wiki and people can update it, but it can be tricky to track things down - e.g. where are the sample apps...

DLinq morphed into which one -- Linq to SQL or the Entity Framework?

What happened to Dlinq? I heard a few years ago that it was abandoned. Was some of its code used to create Linq to SQL or the ADO.NET Entity Framework? Which one? In other words, which of the two latter technologies are a new avatar of the old DLinq? I am learning ADO.NET Entity Framework and since I am just starting out, I believe th...

What is Linq to Entities?

There are so many terms and it is getting hard to learn the thing you are after because of the noise. Is Linq to Entities just the practice of using Linq queries against the entities generated by the ADO.NET Entity Framework? Or, is it a separate technology? If it isn't a separate technology, why does it have another confusing name as ...

How to serialize member functions of ADO.NET for use in RIA Services

I am new to using RIA services and the Entity Framework so this is probably very simple. I am trying to extend an entity class using a public partial class in a separate file. My goal is to simply override the ToString() method. Doing this is as simple as... public partial class ClassName { public override string ToString() {...

ADO.NET Entity Framework - Composite primary key CRUD

Hi all i have following entities as you see BudgetPost has a composite primary key which is a foreign keys to entities Category and Budget. My question is what is the best way to make CRUD? Is there any way to mapp the foreign keys? The simple insert should look like this: Budget newBudget = new Budget(); newBudget.Bu...

Forcing a bridge/join table to become a many to many relationship in EF4

I have a simple database with 2 main tables with a many to many relationship through a 3rd bridge/join table. This 3rd table has an extra field besides the two keys required, so that Entity Framework transforms it into a full entity rather than a many to many relationship between the other 2 tables. I cannot change this third table i...

Problems with EDM associations

Hi, I'm making an OData service and using an EDM to map the structure of my database and specify associations between tables and create Navigation Properties. I've imported my tables into the EDM using the wizard. Things compile fine until I put in associations. I'm sure I've been able to do this before but for some reason it is screwi...