entity-framework

StackOverflow when hosted as WCF - works fine in Console app

I have an app that uses EF (i've seen the 'EF has a bug and StackOverflows' posts thanks). To test my stuff I generally wrap a simple console app around my code, run, rinse repeat till I get it right... So I was pretty surprised to see a stackoverflow when I moved my code to IIS. Right now I get this problem on IIS 7.5 (windows 7 from ...

Entity Framework - Select specific columns and return strongly typed without losing cast

I'm trying to do something similar to this post where I don't pull back all columns from a particular entity, however my framework makes use of inheritence and I lose scope of the entity type after it's been cast to an anonymous type. The structure of my Entity Framework has a base entity called Action. From here I've created two inhe...

EntityFramework: using association or add property manualy

I'm starting to use Entity Framework. Let's say I have to Entity from my tables in DB. Here is the table schema Profiles ProfileId FirstName LastName Hobbies Id HobbyName OwnerId So one profile can have many hobbies. My Entity Framework: ProfileEntity ProfileId FirstName LastName Hobbies (collection of HobbyEntity) note: t...

What can I use POCO for?

I have read some articles on POCO in the enttity framework but still don't understand what I can use it for. How can POCO benefit my projects? ...

Eliminating record duplicates in the Entity Framework database

I work with Entity Framework - add records in the database using classes that map to the DB. But i need to make sure I dont add duplicate records in the database. I assumed that when SaveChanges() is called, it sorts out all the duplicates, but it doesnt. Is there a way to eliminate creation of the duplicate records? ...

Entity Framework, Foreign Keys and EntityKeys

I've got a problem with the Entity Framework and the ForeignKeys. I've got a table "BC_Message_Assets" which has 3 FK's (MessageId, AssetId and StatusId). I create my "MessageAsset" like this MessageAsset messageAsset = new MessageAsset(); messageAsset.MessageStatusReference.EntityKey = new EntityKey("MyEntities.MessageStatusSet", "Id"...

ASP.NET MVC: Get values of a many to many table

Hi, I have a table 'Menus' containing the names of the menus of the restaurant. I also have a table 'Ingredients' containing the ingredients that are available to the menus. I don't have any trouble getting the values out of the 'Menus' table into an IQueryable class (PropAllMenus) Public Class PropAllMenus Private _MenuID As Intege...

Is it possible to track the progress of ObjectContext.SaveChanges?

I'm working on a small console utility to upload batches of data to our hosted SQL server. The total data size can get up to several megabytes. I'd like a way to display the progress of the SaveChanges operation. Is there any way I can do this with the Entity Framework? If not, any recommendations would be appreciated. ...

Having troubles loading related entities (Eager Load) with ObjectContext.CreateQuery (Entity Framework and Repositories)

Here's a bunch of things I tried... hopefully you can extrapolate from it what I'm trying to do and what I'm doing wrong. Okay so I'm having problems with loading related entities when using this DoQuery: public ObjectQuery<E> DoQuery(ISpecification<E> where) { return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Nam...

How-to store a questionary in database

How-to store a questionary in database and maintain it using Enity Framework and ASP.NET ? I have couple of question with certain numbers of answers.This questions are part of an users registration formular. Something like: Aaaaaaaa? Checkbox1 - bbbbbbb Checkbox2 - ccccccc Checkbox3 - ddddddd Checkbox4 - eeeeeee and more questions.....

Dynamic entity in EF1/change model in runtime/add property dynamicaly

Hello all I want to give users the possibility to dynamically add new columns at the runtime. I am using the Entity framework v1 ... I did manage to read as xml and then change ssdl , csdl and msl files and construct new workspace and new object context... But the problem is when i dynamically add new columns in EF model the underlying...

Entity Framework - Include in sub query?

I'm not sure if this has been answered yet, I looked at a couple of questions but I don't think they were quite what I was after. Let's say I have 3 tables: Restaurant 1.....M MenuCategory 1.....M MenuItem I have a L2E query that looks something like this: Restaurant = context.Restaurant .Include(r => r.MenuCategory) .FirstOrD...

Entity Framework - Include in sub query? - Part 2

I'm not sure if this is the right thing to do, I'm sure someone will tell me if it's not. I asked a question (http://stackoverflow.com/questions/1662760/entity-framework-include-in-sub-query) earlier this evening, which was answered very well and has solved my problem. But, I think there could be a better way, so I'm going to re-ask th...

Entity Framework POCO Does Not Fit Nicely with Domain Objects

I have taken a model first approach for a project i'm working on. An example of a class relationship is shown as follows, pretty strightforward: public class Product { public int Id { get; set; } public string Name { get; set; } List<Photo> Photos { get; set; } } public class Photo { public int Id { get; set; } public string...

DataTemplate.DataType=Collection<Entity> ?

Is there a way to create a data template that handles a list of items? I have Contact.Phones (EntityCollection) and I want the data template to handle the list - add remove edit etc. Is there a way to set the DataType property of the DataTemplate to generic EntityCollection? ...

How to prevent dirty write for web forums?

Hi all, As a apprentice for web development, I have no clue of preventing dirty write for web forums. Is there any food for thought? Thanks in advance! I'm working on ASP.NET MVC and Entity Framework. Okay, sorry for misleading. The dirty write here means overwrite changes of another person in the database. While using a Optimistic Co...

Is having two Model objects for one table a common practice with LINQ-to-SQL / Entity Framework?

When using LINQ-to-SQL or Entity Framework, I can easily generate a class for each table which takes care of the CRUD basics: Info info = new Info(); info.Title = "testing"; db.Infos.InsertOnSubmit(info); db.SubmitChanges(); And when I make structural changes to a database table, I can easily regenerate the table's model class (simpl...

Entity Framework and soft deleted records

Hello, All I'm developing WCF service which is using entity framework as data source. Almost all is ok except problem with deleted records. In our database we're using soft delete (mark record attribute IsDeleted = true). My question how to exclude soft deleted records from entity set? For example, entity "A" has entity set "Bs" (FK t...

Localized tables and Entity Framework

Hi all, I have a scenario where I need to localized values of objects in my database. Let's say you have an application that can create animals, if the user is english the value of the "Name" property of an animal would be entered as "Cat" in the UI whereas it would be entered as "Chat" in french. The animal culture table would contai...

Is it possible to NOT map an assocation in ADO.NET entity framework

I'm working on a project that uses ADO.NET entity framework as the ORM framework for getting data in and out the database. This all works great, but there's one association that I don't want to map. At least I don't want the developers to navigate from Product to OrderItem using the association between them. Has anyone tried this scenar...