entity-framework

Using Entity Framework for SQL Compact Edition 3.5 does not respect mode=exclusive property of connection string.

I am using SQL Server Compact 3.5 edition with Entity Framework and I want to have exclusive lock on the database as documented here http://msdn.microsoft.com/en-us/library/ms171817.aspx. However when you pass this in a connection string to Entity Framework it does not respect this at all. An example of the connection string as follow...

How is Entity Framework 4's POCO support compared to NHibernate?

Just wondering if anyone has had any experience using Entity Framework 4's POCO support and how it stands up compared to NHibernate. If they're the same, I'd be very interested in making Entity Framework 4 my ORM of choice if only because it would: Support both data first AND object first development Have a robust LINQ provider Be easi...

solution on SP and EF & Ria Service

As EF 4.0 released, more support to SQL server Stored procedure. Complex Type can be generated automatically for result dataset of SP. But complex type not support by Ria Service. When I try to use ria service combined with EF 4.0, I want to get dataset by SP. This result is not mapped to any entity/table. Some sulutions suggested ...

L2E delete exception

I have following code to delete an user from database: try { var user = from u in db.Users where u.Username == username select u; if (user.Count() > 0) { db.DeleteObject(user.First()); db.SaveChanges(...

L2E these two are the same thing?

Are the following two statements the same? Users user = db.Users.First(u => (u.Username == username)); and var user = from u in db.Users where u.Username == username select u; Users aUser = user.First(); ...

asp.net Dynamic Data Site and SQL Server image datatype

I'm just now created Dynamic Data Entities Web Site. And I have got a problem with image type. for all sql data types generated html elements by fieldTemplate. So, how can I create fieldtemplate for image-view, and image-upload ? ...

Getting the first result from a LINQ query - why does ElementAt<T>(0) fails when First<T>() succeeds?

I have a method AddStudent() which looks for a student with the same name and returns an existing student from the database if there is a student with the same name, otherwise it creates a new student and adds it to the database. I'm curious why se = students.First<StudentEntity>(); succeeds when se = students.ElementAt<StudentEntity>(0...

What's the best way to validate EntityFramwork 4.0 classes?

Hi! I've done a fair amount of searching but I've yet to find an easy way to validate EntityFramework 4.0 entities passed accross the wire via WCF Data Services. Basically, I want to do something on the client like: Proxy.MyEntities entities = new Proxy.MyEntities( new Uri("http://localhost:2679/Service.svc")); ...

Entity Framework 4 code-only reference column name

I created classes: public class Country { public long CountryId {get;set;} public string CountryName {get;set;} } public class Profile { public long ProfileId {get;set;} public string ProfileName {get;set;} public Country Country {get;set;} } and configuration for Profile: public class ProfileConfiguration : EntityConfigur...

Entity Framework 2.0: Cannot update EntityCollection

Let's say we have the "EntityCollection products". Then the following doesn't work: foreach (var product in products) { product.LastUpdate = DateTime.Now(); } As you can also not index an EntityCollection, how do you modify an entity in en EntityCollection? ...

How to add additional data column in EF using ASP.Net MVC 2

My Table: [LocationId] [Address] [ZipCode] When I show a list of Location's, I also want to show the distance from a given zip code. In Asp.Net Web Forms I had a stored procedure that would return the distance and I would call this SP on ItemDataBound on my GridView. Or, I also would have my SP that is returning the Location list...

How to break-down my EF Model?

We have a database app that we're beginning to write some new systems for and I want to redo our DAL, potentially using EF4. As I begin to look at this, it seems that it's a bad idea to just use a single EDMX file for my entire database. When I did this, here is a screenshot of what that looks like (zoomed out as far as I can zoom out) t...

LINQ - How to query a range of effective dates that only has start dates

I'm using C# 3.5 and EntityFramework. I have a list of items in the database that contain interest rates. Unfortunately this list only contains the Effective Start Date. I need to query this list for all items within a range. However, I can't see a way to do this without querying the database twice. (Although I'm wondering if delay...

select top 5 in entity framework

I have [Person] PersonID, EmailAddress, FirstName, LastName [OnlineAccount] OnlineAccountID, PersonID, Nickname Each person is allowed to have 0-* OnlineAccount. In entity framework with C#, how do I select the top 5 Person that has the most accounts? ...

How to log Entity Framework SQL

I'd like to be able to log all the SQL queries executed by the Entity Framework to log4net. What's the best way to do this? ...

Entity Framework Complex Type vs Creating new Entity

Hi, I'm reading about the Entity Framework 4.0 and I was wondering why should I create a complex type and not a new Entity (Table) and a relation between them? Thanks, Ronny ...

EF Forced Concurrency Checks

Hi, I have an issue with EF 4.0 that I hope someone can help with. I currently have an entity that I want to update in a last in wins fashion (i.e. ignore concurrency checks and just overwrite whats in the db with what is submitted). It seems Entity Framework not only includes the primary key of the entity in the where clause of the gen...

Entity framework 4 and multiple database.

Something changes or it still not support this? For example join database1.dbo.Users and database2.dbo.Addresses ...

Changing schema name on runtime - Entity Framework

Hi, I need to change the storage schema of the entities on runtime. I've followed a wonderful post, available here: http://blogs.microsoft.co.il/blogs/idof/archive/2008/08/22/change-entity-framework-storage-db-schema-in-runtime.aspx?CommentPosted=true#commentmessage This works perfectly, but only for queries, not for modifications. Any...

Copying from EntityCollection to EntityCollection impossible?

How would you do this (pseudo code): product1.Orders.AddRange(product2.Orders); However, the function "AddRange" does not exist, so how would you copy all items in the EntityCollection "Orders" from product2 to product1? Should be simple, but it is not... ...