entity-framework-4

C# 4.0/EF - Server-generated keys and server-generated values are not supported by SQL Server Compact.

I have just moved one of my projects into VS2010/fx4.0 and am using a SQL CE database as the backing store. Since moving it to this version of .NET I am now getting this error: Server-generated keys and server-generated values are not supported by SQL Server Compact. My table was defined with a PK of UserName (string) & DoorOpen...

Cannot display edmx generated in EdmGen2 in VS10 using .NET 4.0

I'm trying to generate entity model from my Postgresql database. Under .net 3.5 and vs2008 it worked fine. Unfortunately under vs10 it doesn't. I get an error: "The file references an XML namespace that is inconsistend with the target framework of the project." I assume it's because EF4 is using EDMX v2 not v1, but I cannot cha...

How to reduce Entity Framework 4 query compile time?

Summary: We're having problems with EF4 query compilation times of 12+ seconds. Cached queries will only get us so far; are there any ways we can actually reduce the compilation time? Is there anything we might be doing wrong we can look for? Thanks! We have an EF4 model which is exposed over the WCF services. For each of our entity typ...

How to create relationship between two tables with revisions using Entity Framework

So I am in the process of redesigning a small database (and potentially a much larger one) but want to show the value of using revisions / history of the business objects. I am switching the data from Access to MSSQL 2008. I am having a lot of internal debate on what version of "revision history" to use in the design itself - and thou...

Entity Framework v4 examples and tutorials of conceptual model mapping

In an application I'm writing I have a fairly complicated Database model. I'd like to use EF4 to map this to a whole lot nicer conceptual model. However all the tutorials I've read are with samples of 2 or 3 tables which all map 1 on 1 to the conceptual model. I'd like to learn how to correctly map the database model to a different con...

Cannot perform an ORDERBY against my EF4 data

I have a query hitting EF4 using STEs and I'm having an issue with user-defined sorting. In debugging this, I have removed the dynamic sorting and am hard-coding it and I still have the issue. If I swap/uncomment the var results = xxx lines in GetMyBusinesses(), my results are not sorted any differently - they are always sorting it ascen...

Problem calling stored procedure with a fixed length binary parameter using Entity Framework

I have a problem calling stored procedures with a fixed length binary parameter using Entity Framework. The stored procedure ends up being called with 8000 bytes of data no matter what size byte array I use to call the function import. To give some example, this is the code I am using. byte[] cookie = new byte[32]; byte[] data = new by...

Performing dynamic sorts on EF4 data

I'm attempting to perform dynamic sorting of data that I'm putting into grids into our MVC UI. Since MVC is abstracted from everything else via WCF, I've created a couple utility classes and extensions to help with this. The two most important things (slightly simplified) are as follows: public static IQueryable<TModel> ApplySortOpt...

Entity Framework with 'Get' Stored Procedure that returns Entities

Hello, I am attempting to execute a stored procedure that returns data with exactly the same columns as that of a table Entity I have in my project. I set the 'Returns a Collection Of' property in the 'Add Function Import' dialog to my entity type. I get a NullReferenceException error when executing the stored procedure and on further ...

Does the entity framework ObjectContext maintain references after iterating over the results

the use case that I'm concerned with in this post involves iterating over a large number of entities (100K+) returned from a query. Given the following code snippet: var query = from c in context.Customers select c; foreach(var customer in query) printCustomerStatement(customer); In this example it's clear that the the customer i...

Complex Entity Framework linked-graphs issue: how to limit change set / break the graph?

I have an EDMX containing Sentences, and Words, say and a Sentence contains three Words, say. Appropriate FK relationships exist between the tables. I create some words: Word word1 = new Word(); Word word2 = ... I build a Sentence: Sentence x = new Sentence (word1, word2, word3); I build another Sentence: Sentence y = new Sentence (...

How to model my database when using entity framework 4?

Trying to wrap my head around the best approach in modelling a database when we are using Entity Framework 4 as the ORM layer. We are going to use asp.net mvc 2 for the application. Is it worth trying to model using the class diagram modeller that comes with Visual Studio 2010 where you graphically configure your models into the EDMX f...

Entity Framework 4: which approach is the best

I know similar questions have been asked before. I am starting with a set of xsd-generated data objects (plus the db model is there) and need to persist these almost 1:1 to a single SQL Server database. The number of entities is small (10), and the logic required for the db insert/update/delete (mostly upserts) is thin (albeit there is ...

Entity Framework 4 - Calling a Select / Paging Stored Procedure

Hi guys and girls, I am just starting out with the Entity Framework 4.0 and ASP.NET MVC 2 and have a few questions regarding the use of stored procedures and paging. You can map the Insert, Update, and Delete actions to stored procedures and I have already done this. However for my paging to work I need to map the Select action. Now ...

What is an Entity? Why is it called Entity?

What is the deal with Entities (when talking about the Entity Framework)? From what I understand, it is pretty much an in memory representation of a data store like sql tables. Entities are smart enough to track changes and apply those changes to the data store. Is there anything more to it? Thanks in advance. ...

Entity Framework 4.0 - Code only Reference

Hello All, I am trying to learn EF 4 and its code only features. I tried the following great articles and was able to make a sample application. http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/#reply http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx ...

Is there any way to provide custom factory for .Net Framework creation Entities from EF4 ?

There are a lot of posts about how cool POCO objects are and how Entity Framework 4 supports them. I decided to try it out with domain driven development oriented architecture and finished with domain entities that has dependencies from services. So far so good. Imagine my Products are POCO objects. When i query for objects like this: ...

EF4 with SQL server and SQL CE

Hi all , I have to integrate SQL server in my project . I use SQL server in the server side , and SQL CE in the client side . I used the EF4 editor , created the model . Then copy the same thing to SQL CE model . Then I generated the data bases and every thing is fine. No , I encounter a problem . The save objects in the two model , bu...

How do you determine subtype of an entity using Inheritance with Entity Framework 4?

I am just starting to use the Entity Framework 4 for the first time ever. So far I am liking it but I am a bit confused on how to correctly do inheritance. I am doing a model-first approach, and I have my Person entity with two subtype entities, Employee and Client. EF is correctly using the table per type approach, however I can't ...

Entity framework using Data Repository pattern - DeepLoading

Hi all, I have been implementing a new project which I have decided to use the repository pattern and Entity Framework. I have sucessfuly implemented basic CRUD methods and I have no moved onto my DeepLoads. From all the examples and documentation I can find to do this I need to call something like this: public Foo DeepLoadFoo() { ...