entity-framework-4

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

i have a one entity framework object and when i add it to my project, the connectionstring is add to app.config in connectionstring section, but when i want create new entitycontext and use this connectionstring, this error is appear ...

In EF4 Code first Collection are not lazy loading?

Using Microsoft Visual C# 2010 Express, Entity Framework Feature CTP4. I tried EF4 with code first with something small based on Scott Gu's blog. But it seems that collections are not initialized when retrieving an entity. I get a null reference exception when adding a product to a category. In all the examples I've seen, the collection...

Mapping of stored procedures is all-or-nothing in Entity Framework? (FunctionMapping)

I got the error Cannot find the InsertFunctionMapping for EntityType 'xxx' in the mapping file. Which is fair enough because it is true. But that is because I am happy with EF doing inserts for me. I simply want to override the delete function. I thought that was one of the improvements with EF4? Or is it just that it will bu...

Entity Framework - writing query using lambda expression

Hi, I have just started Entity Framework & linq and write this query var query = from rp in db.UM_RolePermission where (from ru in db.UM_RoleUser where ru.UM_User.UserID == userId select ru.RoleID).Contains(rp.RoleId) select rp; above is working fine and fullfill my need, however I am trying to write t...

ADO.Net Entity Framwork 4 CTP POCO Mappings Error

We are starting on a new version of our product and decided to use POCO objects with EF while keeping backwards compatibility with the existing databases. The problem is that i have a credit card object with a property BillingAddress that is of type Address. In the new database model all address are stored in the address table, in the ...

With entity framework's self tracking entities, can I perform an explicit load?

I wish to return a graph for a "Business" entity. The Buiness entity has a collection of "Contacts". So I basically want this: ctx.Business.Include("Contacts").Where(b => b.BusinessID == id).Single(); The problem is I don't want ALL the contacts for the business. Just those that have a ContactTypeID = x. How can I accomplish this? I ...

Incorporate Triggers Into the Model

Hi All, I have created a data model with in EF 4.0, however I am not sure how I can capture things like Triggers in this model so that if others were to deploy it the Tables, Views, Triggers, etc would go along with it. Is there a way to pull triggers into the model build? Thanks! --B ...

Entity Framework - Is there a way to reorder properties in the EDMX designer?

I'm using Entity Framework's model designer to design the model for a new project. Adding properties is relatively easy, however they're always appended to the entity. Is there a way to reorder the properties once they've been added? This is quite annoying! ...

Create SSDL without entities.

We have a legacy database and want to create a model from scratch. We then want to map the new model by hand to existing tables/views/sps in the legacy database. It it possible just updating the storage schema without creating entities so we can keep the model clean? ...

Calling user defined functions in Entity Framework 4

I have a user defined function in a SQL Server 2005 database which returns a bit. I would like to call this function via the Entity Framework. I have been searching around and haven't had much luck. In LINQ to SQL this was obscenely easy, I would just add the function to the Data context Model, and I could call it like this. bool resul...

How to identify associations flagged as Cascade Delete

I am using EF 4.0 and in my entity data model I have several relationships where I have a 1-to-many associations and have the assocation flagged as Cascade OnDelete. Is there a way to programatically identify these associations for an entity type T? One option I thought of was identifying these associations and in my T4 template annotat...

Entity Framework Code First: decimal precision

I'm experimenting with this code-first approach, but I'm find out now that a property of type System.Decimal gets mapped to a sql column of type decimal(18, 0). How do I set the precision of the database column? ...

Entity Framework 4 exception not being thrown / caught

I am connecting to a MySQL database from Visual Studio 2010 using Net/Connector. This is the entity framework 4 linq query: int timeThreshold = 5; DateTime cutoffTime = DateTime.Now.AddMinutes(-timeThreshold); try { using (var context = new myEntities()) { var un...

Caching POCO objects in Entity Framework 4.0

I have a database with a bunch of reference tables like States, Languages, etc.. I would like to be able to cache these tables and then use those types in any ObjectContext I want. So in pseudo code I want to be able to do something like this var db1 = new PatientObjectContext(); Cache.CacheStates(db1.States.ToList()) var person = new ...

WCF with Entity Framework Error

Error: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection. I am trying to create a WCF service with Entity Framework (VS 2010, .NET 4). When I run it, I get the above error. I read something about editing the T4 template, but it appears that it already has [DataContractAttri...

Get EntityKey without loading referenced Entity

Hi, is it possible to get entity key from EntityReference property without loading it? I tried: entity.EntityKey.EntityKeyValues[0].Value But if referenced entity isn't loaded by EntityReference.Load() method, EntityKey property is null. Thank's a lot! ...

Why doesn't EF 4 generate association for FK relation to column with unique index?

Hi all, I have run into a scenario where Entity Framework 4.0 does not generate an association to an entity backed by a table having a unique index, and I am wondering why. The basic setup is this: Let's say I have two tables in SQL Server 2008 R2 and a foreign key relation: CREATE TABLE [dbo].[User]( [Id] [int] IDENTITY(1,1) NO...

Composite foreign key referencing unique constraint in Entity Framework designer - does it work?

Hi, I'm customizing a COTS product with a rather complex table structure and I'm running into an issue where Entity Framework doesn't seem to know what to do with a foreign key relationship. Here's an example: Order Id OrderDetailId Foo Bar OrderDetailId is a foreign key that references OrderDetail.Id, OrderDetail.Foo2 (combined as ...

The specified type member 'DateTime' is not supported in LINQ to Entities

I am using the latest development version of the connector - 6.3.3 beta to connect to a mysql database via the Entity Framework 4 in VS2010. I have the following Linq statement which uses a TIMESTAMP column - createdDate - in the query. Here is the code: int timeThreshold = 5; DateTimeOffset cutoffTime = DateTime.Now.A...

are entity framework contexts pooled, much like database connections

The guidance for database connections is simple and well understood. Open a connection as late as possible and close it as soon as possible. this is of course OK because of connection pooling. what's the story for Entity Framework contexts? Does the same pattern apply? ...