entity-framework

Database Headaches - Mind not working today

I cant seem to get my head around how to create this Each Bold Letter is a Database Table I need this to work with Entity Framework Product [ Product belongs to one group] Product Group - [Computer] [many to many] [Group has many items] [Product belongs to one Group Item] Product Group Item - [Hard Drive] [many to many] [Group Ite...

Is there any way I can execute this SPROC and get the result with Entity Framework?

This SPROC "returns" a table with two columns: Id, Score. Is it possible to execute this SPROC and include the custom data-type as parameters from within Entity Framework? ALTER PROCEDURE [presenta].[SearchLpi] // The presenta.IdTableType is a table with just one column "Id" @selectedLpis presenta.IdTableType READONLY AS BEGIN...

How long should a DataContext live?

Hi, I was just wondering how long should a DataContext really live. All the patterns and practices books like Dino Esposito's Microsoft .NET: Architecting Applications for the Enterprise tell you, datacontext must not live long, nor should it be cached. But how long is the right time? A whole web request, a unit of work, a transaction, ...

Converting Data Provider for Entity Framework

I am trying to migrate an Entity Framework Model from SQL server to MySql. I'm doing this because I'd like to do a project with Entity Framework to learn more about it, but I am on a shared server that only allows 1 SQL server database (which I'm using), and 5 mysql databases. It's possible that I'd move servers in the future, so I li...

Entity Framework throwing InvalidOperationException when trying to load child tables

I am using Entity Framework with asp .net mvc. I have a repository class that initializes an instance of the entities in the constructor. Let's say I have the familiar customers table that has 1 to many rows in an orders table: Customer has many orders. I have tried the following 2 ways to load the orders associated with customer, but ...

Why won't this LINQ join statement work?

I have this LINQ-query: // types... LinkedList<WeightedItem> itemScores = new LinkedList<WeightedItem>(); var result = from i in _ctx.Items join s in itemScores on i.Id equals s._id orderby s._score descending select new ItemSearchResult(i, s._score); // this fails: ...

How do I update an Entity Reference using a SelectList in edit form?

This is a follow-up to the discussion in this post. I am not sure how to ask the follow-up question in a 2-month-old thread; so I apologize if there is a better way. Anyway, to reiterate I have an ASP.NET MVC Edit form, and one of the fields is a select list. I get the values fine, but I am having trouble to update the primary entity af...

ObjectContext.SaveChanges for specific entities?

Is there a way to save changes for individual tracked objects rather than all the objects in the ObjectStateManager, and I mean something like: ObjectContext.SaveChanges(Contact) ...

Passing parameterized list to view in MVC using Entity Framework

In a MVC project am trying to create a view which has the Title from a parent table and the subsequent list below it from its related Child table. I pulled the tables into the project using Entity Framework and in the controllers namespace created the follwing Viewmodel: public class ServicesViewModel { public ServicesViewModel(Lis...

Full stack framework for Java

Hello everyone, I'm looking for a full stack framework (from persistency to view generation (CRUD)) for Java. I don't have experience with Rails style frameworks, like Grails, but I worked a lot with Hibernate, Struts, Spring ... I prefer a framework that let you naturally modify the business domain design with the less effort ( i.e. w...

Creating a non mapped property in an entity (entity framework)

Hi all, I want to create a custom property on one of my entities mapped from the database, however this property is not mapped to the database, I created the property using partial classes but when trying to compile I get an error telling me that the property is not mapped. Is there an attribute or something I should add? Thanks in advan...

How to get Entity Framework and MVVM to play nicely together?

I'm would like to use both EF and MVVM and am trying to see how they fit together. I can't find much in the way of examples so hope you guys can answer a few questions. Let's say I have a single table in a database called Customer. I run the EF designer and get a data model. The next step is to run some linq to get data out of the data...

Getting ID of recently created entity - ADO Entity Framework

Say you create an object and saving to database by using ADO Entity Framwork as in the code below. private void CreateAddress(BizObjects.Address address) { var entity = new EntityFramework.Address(); entity.Line1 = address.Line1; entity.Line2 = address.Line2; entity.City = address.City; entity.State = address.State;...

Is it good to use a static EF object context in an MVC application for better perf?

Let's start with this basic scenario: I have a bunch of Tables that are essentially rarely changed Enums (e.g. GeoLocations, Category, etc.) I want to load these into my EF ObjectContext so that I can assign them to entities that reference them as FK. These objects are also used to populate all sorts of dropdown controls. Pretty stand...

Entity Framework sub query

How to write sub queries like these in EF? select * from table1 where col1 in (select col1 from table2 where col2 = 'xyz') or select * from table1 where col1 not in (select col1 from table2 where col2 = 'xyz') I tried something like these from t1 in table1 where (from t2 in table2 where col2 = 'xyz' select t2.col1).Contains(t1.col...

Entity Framework V1, PredicateBuilder, Linq to Entities failed to resolve method

Helo, i have the following code which should filter entities. Half of the code is working by i'm trying to refactor my code to get some sort of 'subfilters'. Basically i have the following call to filter a Users entity collection: var result = ctx.GetUsers().WithGroups("Administrators","Users").ToList(); WithGroups has the followin...

Using .NET Entity Framework in Medium Trust Enviroment like Mosso/Rackspace Cloud Hosting

I have an application that is using .net's Entity Framework. This application runs fine on my local machine and my local server. However, trying to run the app on mosso which runs in medium trust returns an error. I am not sure how to appropriately use entity framework in medium trust. I have the entity model in a separate project ...

Having Entity Framework trouble

I'm trying to add a ProfileProperty into the ProfileProperties table using ObjectContext.AddObject. The db fields for the ProfileProperties table are: ProfilePropertyID ProfilePropertyDefinitionID UserID PropertyValue The db fields for the ProfilePropertyDefinitions table are: ProfilePropertyDefinitionID PropertyName The variables...

How to write a Mock Repository to test WCF RIA Domain Service build on top of Entity Framework Context.

Hi, I need to write a test layer to Test my WCF RIA Domain Service layer which is build on top of Entity Framework context. I have come across some patterns which suggest to use a repository and then use the Domain Service factory to intilize the domain service with a repository instance to use. One of the sample which fits the requirem...

entity framework multiple many to many queries

I have a simple model for security where there are: Users Roles Paths and many to many links between these tables, so a user to roles, and roles to paths. I am trying to write a function so that from a username and a path it will return a bool value based on whether the user has access to that path. How can I do this with the entity ...