entity-framework

Adding a logical key to a View in SQL Server Manager

The .NET Entity framework is giving me the following error: "The table/view 'Foo.dbo.vwFoo' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity you will need to review your schema, add the correct keys and uncomment it." The view is a collection of a varie...

Getting Error 3007 when I add my Entity Model

I am getting an error 3007 when I add my entity model to my solution. I found these links: Good explination Short answer About this error: Error 1 Error 3007: Problem in Mapping Fragments starting at lines 89, 94: Non-Primary-Key column(s) [Person_ID] are being mapped in both fragments to different conceptual side propert...

One entity object for many entity models

Hi, it's possible to have one entity object (class, e.g. User) for more entity models (EDMX)? I have two datamodels in which i want to share user tables. ...

Entity Framework 3.5 - How to load children

My questions is probably very simple, how do you load children/subclasses. There is no "load" or anything like it that I can find to have the context load the children. the context class is of ObjectContext type, see below: public partial class RTIPricingEntities : global::System.Data.Objects.ObjectContext Product Product.Mo...

Auditing in Entity Framework.

After going through Entity Framework I have a couple of questions on implementing auditing in Entity Framework. I want to store each column values that is created or updated to a different audit table. Rightnow I am calling SaveChanges(false) to save the records in the DB(still the changes in context is not reset). Then get the added ...

How to write the code for import function from a stored procedure in EF 3.5?

I have a stored procedure GetMyTime. It has one parameter int PersonID, and return a datatime. After add it to EDMX and import it as a function. Then I try to mock up 4.0 to write a code as below: public ObjectResult<Nullable<global::System.DateTime>> GetMyTime(Nullable<global::System.Int32> PersonID) { ObjectParamet...

Implementing repository pattern with entity framework. Problem resolving entity in scope of repository.

Hi, I'm trying to implement the repository pattern using a generic repository like the one found here: Implementing Repository Pattern With Entity Framework I've created a test suite (I'm using NUnit) to test the repository but I've been having issues. Here's the error I'm getting: MyBusiness.Test.Domain.RepositoryTest.SelectCol: ...

What do you name your Entity Framework data model?

With your LINQ or Entity Framework data models... what do you use as a standard naming convention for your data models? Or do you even have a standard? Using Northwind as the example... NorthwindDB? NorthwindData? NWDB? ...

Committing new data to database via EF, Errors ensue with Attaching/Adding

So I'm starting out with EF on my website (C#) and Ive run into a bit of a snag. A user can either create or modify data and they will do that with the selection screen (page 1). If a user selects to create new data, I will perform the following code: Program newProg = new Program(); using (DatabaseEntities context = new DatabaseEntit...

Derived fields in ado.net entity framework

I have a persistent class that looks like this: public partial class Unit { public string Name { get; set; } public long LengthInMM { get; set; } public decimal VolumeCoefficient { get { return LengthInMM * LengthInMM * LengthInMM; } } } Now the derived field (VolumeCoefficient) never gets explicitly ass...

whats the recommended Data access layer design pattern if i will apply ado entity frame work later?

I am creating a website and using Linq to SQl as a data access layer, and i am willing to make the website can work on both linq to sql and ado entity framework, without changing many things in the other layers: business logic layer or UI layer, Whats the recommended pattern to achieve this goal? can you explain in brief how to do that...

What is the state of ado.net entity framework?

I get the impression that Microsoft is putting a significat investment into this framework, conversely I have heard the who's who (who?) of the object relational professionals think it sucks, and I have to agree. I have asked a simple question a while ago and I do not think it is unsolvable, given the commonality of that problem it shoul...

Extending Entity Framework

I'm developing a program which allows users to input some information which then gets stored and dynamically creates an image based on it. I was going to use the Entity Framework to do the work with the data, but then I obviously need a way to generate the image. My thinking was that the "correct" way to do this was to somehow extend th...

C# Silverlight Datagrid - ADO.Net Data Entities CRUD?!?!

Hello! I have followed this tutorial which allowed me to create a Silverlight Datagrid that pulled back data from an SQL Server Database. My next step is to be able to perform CRUD on this set of data (hopefully via the datagrid by simply editing the fields for update etc. and having this post back). I have been informed that the datagr...

Entity Framework - Programmatically add FunctionImportMapping

How to add a FunctionImportMapping programmatically using classes from the System.Data.Entity.Design namespace? This blog post discusses the modifications that need to be made to the EDMX: http://blogs.msdn.com/adonet/archive/2007/09/14/how-to-map-stored-procedures-using-the-ado-net-entity-framework.aspx I want to be able to do this p...

LINQ to Entities and grouping with many-to-many association.

I have a Product and Category entity in many-to-many association. I am trying to display the category count for each product. So far, I have come up with this: Dim context = new Context() Dim products = context.Products() Dim productsByCategoryCount = From product In Products Group product By productId = product.productId Into produc...

Exception thrown when trying to access an ADO.NET Data Service Built with the Entity framework

While trying to use the entity framework and ado.net data services, I'm hitting a real headscratcher. Before the request even makes it to my code, i get a WCF exception (Exception at the bottom). It's not very helpful at all. All my entites have primary keys and all properties on all entities are public. Any ideas what can be causing th...

Add empty entry to combobox bound to entity list

I use a ComboBox which is bound to a List<> of Entities. How can I add a "Not selected" entry to the combobox? Adding null to the list results in empty combobox. ...

Entity Framework IoC Integration (Spring.net)

I Need to configure Entity Framework in Conjunction with NCommon to work with Spring.NET IoC Container. I Noticed about the Microsoft CommonServiceLocator project to abstract DI Containers used in the NCommon project, but I can't still find an exaustive example of how implementing NCommon Repository for Entity Framework using Spring.NET ...

MySql and Entity framework randomly gives Schema specified is not valid error

I'm using Entity Framework to access my MySQL database. The model was generated using EDMGEN2 and everything works great. I can do all my linq-to-entity query goodness... ...until an indeterminate amount of time passes and I get "The ProviderManifestToken '5' is different from '5.1' that was encountered earlier" error. Why is it encount...