entity-framework

Does Entity Framwork round off decimal value to nearest integer?

Hi all, I'm using Entity Framework and MS SQL Server 2008. It seems that Entity Framework always round off decimal entity attribute to nearest integer which is really annoying. Have you seen this problem before and what's your solution? Thanks! ...

WCF - use same type across multiple services

We are starting to build a common entity model using Entity Framework v1. The goal is to expose various common operations as services that can be used by several different clients. The problem we are running into is reusing the types across multiple services. Example: Service1 (at http://example/service1/service.svc) returns a List S...

Can MySQL .NET Connector 6 Be Used w/ Entity Framework 4?

Does anyone know if the MySQL .NET Connector 6 can be used w/ the Entity Framework 4 in Visual Studio 2010 Beta 2? ...

Can Entity Framework map two associations into a single navigation?

I have two simple tables as described here... Table = Person PersonID (int, PrimaryKey) FirstName (char) LastName (char) Table = Related RelatedID (int, PrimaryKey) Person1 (int, ForeignKey for Person.PersonID) Person2 (int, ForeignKey for Person.PersonID) Relationship (int) The generated entity fo...

SaveChanges() problem

Hello I have this piece of code: Schedule chk = _entities.Schedules.Where(x => x.ScheduleStart == schedule.ScheduleStart && x.ScheduleEnd <= schedule.ScheduleEnd).FirstOrDefault(); if (chk != null) { chk.Discontinued = true; _entities.SavingChanges(); } basically if something exists in database with that criteria, set disc...

EF-Reference.Load() - There is already an open DataReader

Looks like EF Reference.Load() is not working without MARS? Is that right? ...

Adding a collection, loop needed?

Hello I have this code: Schedule s = _entities.Schedules.Where(x => x.ScheduleID == schedule.ScheduleID && x.BookingObject.BookingObjectID == bookingObjectID).FirstOrDefault(); if(s == null) s = new Schedule(); s.ScheduleStart = schedule.ScheduleStart; s.ScheduleEnd = schedule.ScheduleEnd; foreach (var t in schedule.Timetables) ...

Mysql EF Stored Procedure, did not generate C# part

I have mysql database with a store procedure. When I added to schema, I found in edmx this: <Function Name="abzac_GetByPage" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="paragraph" /> This I have in SSDL part. But nothing in Designer.cs file...

EF 1.0 during creation

Hi folks, I've a strange problem using EF1.0... my problem happenin' only during a creation and I didn't find anything on many forum's thread. > System.InvalidOperationException: The source query for this EntityCollection or EntityReference cannot be returned when the related object is in either an added state or a detached state and w...

Read only Search function. Stored Procedures or IQueryable with POCOs and Ef 4.0

We have some search functionality that can return tens of thousands of results from the db although it will only fetch the rows needed to be displayed into e.g. first 10 records. When the next page is requested, we hit the db again. It searches our database based on a set of variables and this search can then be refined which will resul...

How to wrap .Net data provider for entity framework

I will try to explain the question again: I wanted to introduce logging in Entity Framework in such way that the query and its result along with the time the query took to execute can be logged. Jaroslaw Kowalski has wrapped the provider to intercept communication between Entity Framework and the original provider. It also provides trac...

Mapping POCO to Entity in Entity Framework

I use EF for Visual Studio 2008, so I don't have POCO integration with EF. Since we have a n-tier application, we're mapping POCO to entities constantly, entities aren't thrown to the upper layers, I do mapping with Automapper and manually also. The big problem we have is when mapping from POCO to entities. If I'm adding a new entity ...

ADO.NET Entity Model + DataGridView: How to write changes to database

I have an ADO.NET Entity Data Model and want to plumb up a DataGridView for CRUD operations. How should I go about this? For a read-only DataGridView I've been doing the following TimeTrackEntities tte = new TimeTrackEntities(); //Entity Data Model ObjectQuery<Days> DayQuery = tte.Days; dgvDays.DataSource = DayQuery; ...

Entity Framework: "Store update, insert, or delete statement affected an unexpected number of rows (0)."

I am using Entity Framework to populate a grid control. It sometimes when I make updates I get the following error: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries. I can't figure out how to re...

Master / Detail with Entity Framework

I have a table, say STUDENTS, that is related one-to-many to another table, CLASSES. I created an ASP.Net form to take input of a new student, including selection of one of the classes from a combo box. This is a small but multi-tier app, and I have started using the entity framework. So the EF generated classes for both those tables. ...

How to wrap Entity Framework to intercept the LINQ expression just before execution?

I want to rewrite certain parts of the LINQ expression just before execution. And I'm having problems injecting my rewriter in the correct place (at all actually). Looking at the Entity Framework source (in reflector) it in the end comes down to the IQueryProvider.Execute which in EF is coupled to the expression by the ObjectContext off...

Eager Loading with Entity Framework and Asp .net mvc (From a rails background)

I have a few tables that reference the same table. For example: Person has an address. Business has an address. When using the models I would like to do this in the controller: person.Address.Zip business.Address.Zip I'm coming from a rails background where I can just declare a relationship and have all the above functionality. Forc...

How to make apps access my model without have to spread my model DLLS through them

I have an architectural question. We have many applications in our company and we are planning to use ASP.NET MVC and Entity Framework in our future projects. The next project that we need to implement is a central authorization/authentication system. There is no option to use an existing one for reasons that doesn't mater right now. Thi...

Entity Framework: Inserting new entity associated with another entity

I have two tables FilesystemEntries and CacheEntries where there is an association of 0..1 CacheEntry per FilesystemEntry (that is a FilesystemEntry can have a null CacheEntry, but not vice-versa). Initially, the CacheEntry for all FilesystemEntries is null. I'm having trouble changing this (adding a new CacheEntry). The code (truncated)...

Difference between LINQ to Entities with and without ObjectResult

I have the following LINQ to Entities query... var results = from c in context.Contacts select c; which works fine in returning a collection of contacts. But I have seen sample code that does this instead... ObjectResult<Contact> results = (from c in context.Contacts select c).Execute();...