entity-framework

ADO.NET EF 4 vs. DataSets (of any kind)

Hello, I've been reading updates on Data Sets vs. Other ORM's like ADO.NET Entity Framework, but a lot of them refer to the older version, so with EF 4 as an option today, what is people's opinion for data sets vs. EF 4, which is better, worse? I like EF 4 because: The designer finally works well. The variation of model options (POC...

Entity Framework v4: Preventing Storage Model Overwrites by Update Model Wizard

In my Entity Framework v4 project, I have a table with two columns that are computed by the database (via triggers, etc.). In order to get EF to properly insert records into the table, I have to manually mark the columns as "Computed" in the EF Storage Model (the StoreGeneratedPattern attribute), which is not supported by the designer -...

Using Entity Framework Set DateCreated on a poco object when saving.

I am evaluating Entity Framework 4.0 and I am wondering how I can get access to entities just before they are saved to set DateCreated. With NHibernate this could be done using a listener, if that helps? ...

Entity Framework calling MAX on null on Records.

When calling Max() on an IQueryable and there are zero records I get the following exception. The cast to value type 'Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type. var version = ctx.Entries .Where(e => e.Competition.CompetitionId == storeComp...

Entity Framework 4 selective lazy loading properties

Is it possible to load an entity excluding some properties? One of this entity's properties is expensive to select. I would like to lazy load this property. Is that possible? ...

Entity framework model creation

When using the Entity Framework there are basically two ways to create your model. You either create the model in SQL server or in Visual Studio EF designer. Those are outlined below. Start with Database You first create the model in your SQL server DB then point EF to create the .edmx file for you. By using this approach you can use ...

Change db table name in EF4 (entity framework 4)

Does anyone know how to change the mapped db table for an entity in EF4 (entity framework 4)? Later edit: I think i've found the place where the table names are defined, in the model browser. But their names are readonly, so it's not possible to edit them using the designer. Also, there's no reference (from what i've searched) to the ta...

Silverlight + WCF RIA + how to include a conditional set of child records (not all but a set)

Hello everyone! I've got a problem with loading related data via WCF RIA and Entity Framework - please help me - i don't know how to solve it. I have Room <-- RoomRecords(contains startDate/endDate fields and reference to parent Room) and I have to load RoomRecords where e.g. start date >= 1.07.2010 and endDate <= 15.07.2010. Parent R...

Entity Framework 4: Problem mapping column to complex type

I have a table with about 30+ columns, so i decided to group them using complex types. When trying to build the assembly, i get the following error: Error 3023: Problem in mapping fragments starting at line 933:Column TableName.ColumnName in table TableName must be mapped: It has no default value and is not nullable. One of my complex t...

Issues with Entity Framework Self Tracking Entities and ASP MVC .NET and Managed Extensibility Framework

BIG EDIT: This problem is probably being caused by MEF! I'm using a service oriented architecture and have all my MVC controllers perform actions through the services. I have a base service that looks like this: public abstract class BaseService { protected MyObjectModel context; public BaseService() { co...

Is there any alternative to DateTime.Ticks or DateTime.TimeOfDay in Linq-To-Entities?

Hi there! I'm writing a log parser for an asp.net mvc2 web application. I use Entity framework as a model and logging is done both using my manual engine together with SqlServer2008 CDC feature. When inserting, or editing a row in a database, the action is being logged. However, there's a small lag between occuring changes in actual ta...

ObjectSet and ResultSet on stored procedure on EF and Domain Service

In EF 4, the default ObjectSet is available for each entity. For example, I have table Employee, after gererated Entity Model, EF will create ObjectSet on Employee. Then when using wcf ria service, the default query will be like: public IQueryable GetEmployee() { return this.ObjectContext.Employees; } With objectSet, I...

Problem with data binding in xaml through a RIA Domain Service

I have an entity framework with a many-to-many relationship between Customers and Contacts. I have generated a Domain Service Class and added the following method manually. public Customer GetCustomerById(int Id) { return this.ObjectContext.Customer.Include("Contacts").SingleOrDefault(s => s.Id == Id); } I now want to create ...

Entity Framework simultaneous multiple inherited types

I am trying to use inherited types with EF, which has been all cool and gravy until now. I have a base type (Person) and two types that inherit person (Employee & Customer). I run into a problem when I want a person to be an Employee and a Customer at the same time. For example: Person person = db.Persons.Single(p => p.id == id); if (...

Trackablecollection problem in EF

I newbie in EF. I have Table A linked together to table B, by passing a primary ID from table A which is a secondary ID on table B Iam trying to retrieve an object from table B. But I am getting trackableCollection'1[Object name(from table B)] Any suggestions? I am trying to retrieve using stored proc here is the code: select * from t...

Entity framework issue with WCF and IIS

Hello all, I have a WCF service, a MS SQL database, and the Visual Studio 2008 development environment all in one machine. The operating system is Windows Server 2008 with IIS 7 on it. The IIS 7 hosts my WCF service and the service is connecting to a database using Microsoft Entity Framework. Currently, I'm testing the WCF service using...

Deciding between NHibernate vs Entity Framework?

What are the main advantages and disadvantages of NHibernate and Entity Framework 4.0? (While tagging my question, I've noticed more NHibernate tags than EF. Is NHibernate more popular?) ...

Joining Linq Expressions

I'm working with the new EF4 CTP4 although I don't think this has much to do with that. I am trying to set up a system where I can add auditable fields for our database automatically. What I'm trying to do is combine the following two expressions a => new { a.CreatedBy, a.CreatedTime, a.UpdatedBy, a.UpdatedTime } and...

How would you implement a form submission templating system

hello, I need to implement a form tamplate system. The form needs to be very dynamic. It will need: Multiple textboxes Multiple dropdown menus Multiple Number fields Multiple Date fields Single Image field Single Submit button Any or all of these fields can be blank but must follow the field type. Therefore letters cannot go in numbe...

Entity Framework/L2S creating new table in DB and Load it to the context?

Is it possible to create a new table programatically in EF or L2S and load it to its context? We have this application that requires to create a table at runtime and do some CRUD activities to that table. Is this possible? If not, any advice? ...