entity-framework-4

Programming against interfaces & Entity Framework 4.0

I'm trying to figure out if it would be possible to stick to the mantra "Program against an interface, not an implementation." while using the Entity Framework 4.0. While I found a page explaining how to stick to aforementioned rule while using Linq-to-SQL (look here) I'm very keen to know if it would be possible to do that with the Ent...

Linq To SQL migration to Entity framework 4

We are planning to migrate to .net 3.5 and evaluating Linq To SQL and Entity framework. Considering what people are saying every where on internet that EF 1.0 is buggy, complex, has suboptimal designer support etc, if we pick Linq to SQL - do you think we will be able to migrate it to EF 4 when the time comes? The question arises becaus...

Entity Framework and WCF Data Services : Calling business logic after persisting entity

We have an Entity Data Model which is used by a WCF Data Service that needs to run some business logic after persisting an entity to the database. In this case it needs to pass the id generated for the persisted entity to another service via a WCF web service call. The question is how do we run some business logic after saving the enti...

How to Clone POCO entity and add to context

I am using EF4 and I have create POCO objects with proxies from my database structure . I have a POCO (object) which has lots of relationships to other entities. I created a deep copy of the object using DataContractSerializer and BinaryFormatter and lets call it clonedObject. function used for cloning is: public T CloneProxy<T>(T sou...

how can I add table prefixes to tables created using model first in EF4?

My client has a db table naming convention that requires me to prefix all tables with an application specific prefix - like "myapp_" - I am using EF4 with the model first approach. I can specify a custom db namespace but they do not want to introduce a new namespace for this app - none of their other apps use namespaces other than dbo....

Base Types with EntityFramework CodeOnly

I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework. I am having a lot of trouble with 'base types' in the Code Only model of the Entity Framework. When I try to run this code using a DbContext with a DbSet<Template>, I get the following error. A The navigation property 'Flags' is mapped t...

how to make entity method available at client side?

EF + WCF Ria Service: Suppose I have entity People, because it is a partial class, so I can extend it to add a method to it: partial class People{ static string GetMyString(){ //...... return string; } } then at client side, I want to method GetMyString available for entity People. what's the best way to implement this?...

DDD - Enity Framework 4 and ncommon

I'm trying to get EF4 working with ncommon 1.1 which provides DDD patterns such as UnitOfWork, Specification, Repository. The NCommon configuration line is throwing the following Exception: SynchronizationLockException occurred Object synchronization method was called from an unsynchronized block of code. The actual code throwing the...

Getting the connectionstring in .net 4

I want to get a connection string from the app.config file. connectionString = System.Configuration.ConfigurationSettings.AppSettings["DBEntities"]; But it doesnt work. It's empty. I cannot access the System.Configuration.ConfigurationManager because it's .net 4. How can i get my connection string from the app.config? Thanks ...

Entity Framework 4 - prevent basic caching

If I have an entity framework 4 context, normally if I have run a query like: db.Invoices.Where(I => whatever); and then later run something else: db.Invoices.Where(I => something_else); any objects returned from the second query, which were also returned from the first, will not be loaded from the database. EF will just take the ...

Design questions re: EF4 and ASP.NET MVC 2

I have a couple of questions about good design with EF4 in an ASP.NET MVC 2 project. First, validation. Should I place my form validation within my entities' SavingChanges events? How would I obtain the form data within the partial class? Or is there a better way to do it? Second, maintaining logged in users. I come from a PHP back...

Error when trying to change the multiplicity of a relationship in EF4

I'm trying to build a relatively simple game review site. There should be a 1-to-1 relationship between games and reviews (each review is for one game, and there will only ever be one review for a game). My tables are pretty simple. The relevant parts are: Reviews Table: ReviewID - int, primary key Text - text GameID - int, foreign k...

Entity Framework 4 with Oracle

I installed the ODP 11 lateset version, which suposed to wupport EF4. But when i'm trying to add entity data model in the VS2010, I don't have the option to select Oracle Database. Is there anything else i need to do? Also, I have running on my pc Oracle Express 10g - Is the 11 ODP will work with this DB? ...

Singleton object disposal

I've been doing some playing around with POCO objects and EntityFramework. Because of this I have to write my own Context and Repository(s). I would like all repositories to use the same context instance so changes are shared between them. To facilitate this I coded my Context as a Singleton. This way instead of getting a new context and...

Entity Framework unitofwork vs self-tracking entities

This questions stems from a n-tier application. (non-WCF - only separate assemblies) Should I use a unitofwork pattern and keep my object context around for entity change tracking? or Should I use self-tracking entities and always dispose my object context after a query, insert, delete, etc... and have the entities track themselves...

Entity Framework how to make an EntityObject self-tracking

From what I can tell in order for an object to be self tracking it needs to implement IObjectWithChangeTracker. Entities out of the box (made with EDMX generated code) implement IEntityWithChangeTracker. Is there any way to make a EDMX code generated entity self tracking? Thanks! ...

Entity Framework use model for different providers

I have an entity 4.0 model that is using a SqlServerCE database as its provider. On the server I want to use the same project and just switch out the connection string to use the actual SqlServer database. Here is my connection string <add name="Entities" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|re...

oData and EF4 - different result for the same query

I am running the following query... (from txRx in TxRxes where txRx.Serial == "someSerial" select txRx).Single().TxRxModes.Count() When I run this on the database using EF4 in LinqPad, I get the correct result of 1 back. When I run exactly the same query on the same database through oData (using the same underlying context) I get 0. ...

Dynamic Fetch an Inheritance in Entity Framework 4 POCO

Hey guys, Is there anyway to make a dynamic fetch in entity framework 4 If you have some inheritcance where a and b inherit from c Can you call one linq query to get a list of a, and b using the data set for c? ...

"Collection was of a fixed size" Exception in EF4 with POCO

I am using EF4 with WCF and POCO. I removed all virtual keyword in POCO entities. I have Employee and Team entities and relationship between both is 1:N, means that one employee can be allocated only one team. And I'd like to add new employee with existing team. Following code is in the client side. private void btnAdd_Click(object se...