entity-framework

Entity framework 4.0 compiled query with Where() clause issue

Hello, I encountered with some strange behavior of System.Data.Objects.CompiledQuery.Compile function - here is my code for compile simple query: private static readonly Func<DataContext, long, Product> productQuery = CompiledQuery.Compile((DataContext ctx, long id) => ctx.Entities.OfType<Data.Product>().Where(p => p.Id ...

Entity Framework 4 and persisting foreign key relationships

I am a pretty much a newbie to Entity Framework (specifically version 4) and I am trying to understand an issue I have. I have an ASP.NET MVC2 project I am using with Entity Framework 4 and a Repository class. I have a simple foreign key relationship that I have defined. When I run my MVC project I am able to load the MVC form and updat...

Help me with LINQ to entities query, please

I need to build a query to the entities to get records including: AssetWeapon, PersonOut number of records with IsIn = True, number of records with IsIn = False, name of the month of StartTime, Records should be grouped by AssetWeapon thank you guys! ...

Entity Framework and Multi Language Databases

Hi, I was just wondering if there was any best practices when using Entity Framework with multi-language databases? My database design for handling this is to have a separate table for all of my translations: [Product Table] ProductID PK NameId FK DescriptionId FK [Translation Table] TextId PK LanguageId TranslationT...

WCF 4.0 & Sync Framework 2.0 & Entity Framework 4.0 & ASP.NET MVC 2.0 & auto generated code

Hello, I have to use Sync Framework 2.0 in our WPF app that will contain SQL Compact 3.5 and will synchronize with SQL Server 2008. I followed this video : http://download.microsoft.com/download/6/7/3/6730f0e7-a649-4656-96ab-150c7501a583/IntroToSyncServicesADODetNet_HighQuality.wmv. But instead DataSet I've used EntityFramework 4...

Best practice for structuring a new large ASP.NET MVC2 plus EF4 VS2010 solution?

Hi, we are building a new web application using Microsoft ASP.NET MVC2 and Entity Framework 4. Although I am sure there is not one right answer to my question, we are struggling to agree a VS2010 solution structure. The application will use SQL Server 2008 with a possible future Azure cloud version. We are using EF4 with T4 POCOs (mode...

Is there an ORM that allows a "plugin" to extend the database?

So, I've been searching for the answer to this, but I can't find anything I have an Entity Framework Model (MyModel1) - for now, we'll say this contains a "Users" table It's part of a big app, that has a references to an "Addresses" project The addresses project contains an Entity Framework Model (MyModel2), this contains a Users tabl...

How to update a record without selecting that record again in ADO.NET Entity Framework?

Hi all I am doing something like this - void update(ClasstoUpdate obj)//obj is already having values to update... { var data= (from i in Entityobject.ClasstoUpdate where obj.Id==i.Id select i).FirstorDefault(); data.Name="SomeCoolName"; EntityObject.SaveChanges(); } I want to perform an update without a...

How can I implement CRUD operations in a base class for an entity framework app?

I'm working a simple EF/MVC app and I'm trying to implement some Repositories to handle my entities. I've set up a BaseObject Class and a IBaseRepository Interface to handle the most basic operations so I don't have to repeat myself each time: public abstract class BaseObject<T> { public XA.Model.Entities.XAEntities db; ...

How can I check to see if poco entity framework object has been materialized?

I am using EF4 poco objects and I have changed my t4 template to add a partial method for every property. The partial method is called in the setter. When the objects are materalized the code in the setter gets ran and therefore my code gets ran. I do not want my code to get ran with the objects are being materialized. The way to do ...

EF recovery from invalidoperationexception caused by server being down

I had a windows service relying on EF, and it was running fine until the server went down. The problem was after the server went up again, it didn't fix itself and still threw the error: INTERNAL ERROR: Execution of the command requires an open and available connection. The connection's current state is broken. Not being very prof...

Entity Framework with RIA services, Silverlight - tradeoff of decoupling versus rapid development

I've been playing around lately with Entity Framework, WCF RIA Services, and Silverlight 4. I'm impressed by how rapidly you can develop an application with these tools, and you get a lot "for free", such as the Silverlight UI automatically knowing about certain validations that are included as DataAnnotations on the EF model. However,...

What is the best way in assigning foreign key when using entity framework & LINQ to Entities?

Hi all, I need to know the best practice of creating an entity object and assigning the foreign key. Here is my scenario. I have a Product table with pid,name,unit_price etc.. I also have a Rating table with pid (foregin key),rate,votes etc... Currently i am doing the following to create the rating object: var prod = entities.Product....

can we build ADO.NET entity framework based on MYSQL database?

Hi guys, I am using MUSQL Database extensivly in my projects, can we build ADO.NET entity framework based on MYSQL database? if yes, any articles?? thanks ...

Entity Framework : interrupt running SaveChanges

I have a unique ObjectContext, on which I perform a SaveChanges(). This operation takes some time (~60 seconds). This operation is executed in a thread. My user have a "Cancel" button on the screen. I'm able to stop the thread, but if the SaveChanges() has already started I can't find anyway to cancel it. In fact I found no way to acces...

is it that easy working with ADO.NET Entity framework in real programming?

HI Guys, I was watching these videos series about Entity Framework: http://msdn.microsoft.com/en-us/data/ff191186.aspx is that easy building application in real world programming??? and is it ....reliable...has good performance... "I am a graduate.." thanks ...

Can I perform some processing on the POST data before ASP.NET MVC UpdateModel happens?

I would like to strip out non-numeric elements from the POST data before using UpdateModel to update the copy in the database. Is there a way to do this? // TODO: it appears I don't even use the parameter given at all, and all the magic // happens via UpdateModel and the "controller's current value provider"? [HttpPost] public ActionRes...

Designing a data model in VS2010 and generating ORM code, application

Simply put: I have a database design in my head and I now want to use Visual Studio 2010 to create a WPF application. Key is to use the VS2010 tools to take much as possible manual work out of my hands. -The database engine is SQLite -ORM probably through DBLINQ -Use of LINQ -The application can create new, empty database instances ...

Why does the entity framework need an ICollection for lazy loading?

I want to write a rich domain class such as public class Product { public IEnumerable<Photo> Photos {get; private set;} public void AddPhoto(){...} public void RemovePhoto(){...} } But the entity framework (V4 code first approach) requires an ICollection type for lazy loading! The above code no longer works ...

What are some good Repository pattern examples for use with Entity Framework 4.0?

Can anyone refer me to good and complete/semi-complete examples of using EF 4 with the Repository pattern? Thanks! ...