entity-framework

Entity Framework - Inheritance

I am just starting with Entity Framework and have the following problem: I have a Site entity which contains a navigation property Paragraphs. I have multiple entities (i.e. ImageParagraph, LinkListParagraph) that should be inherited form Paragraph. I would like to query for a Site object and access its Paragraphs and work with them d...

Entity Framework: Model doesn't reflect DB

I'm probably thinking about this all wrong but I have the following db tables: When I run the EF Wizard in VS2008 I get the following model: You'll notice that in the EF model shows that the Entity has no field for EntityTypeID or EntityStatusId. Instead it shows it as a navigation property, so the field appears to not be addressa...

.NET ORMs - What advantage does NHibernate (or SubSonic or whatever) give over using Entity Framework?

I'm wondering, what are the main reasons for not to use the built-in Entity Framework? I've read that it's disliked because of its bad implementation, but is this all? And is it still true? (I don't remember the publish date of the article) I know there exist a lot of options, but why should I consider switching? I only have a little e...

Entity Framework: Singletonish ObjectContext - Good, Bad, or Overthinking?

The idea is to create a class that exposes a context but handles the storage of it in a web application. Currently this is what I have: public class EntityContext { private static String MAIN_CONTEXT_KEY = "MainContext"; private static TISQLEntities _context; public static void RemoveContext() { if ( ...

Entity Framework: Why does the database get hit if the data is in the context?

Why would the database be hit to find a record that is already represented in the ObjectContext? So here's what I thought would happen when you query: SiteUser someUser = context.SiteUser.Where(role => role.UserID == 1).ToList()[0]; Junk example but the idea is that I want to get a user from the table with the id of 1. Now assume thi...

How to map 2+ tables to an entity in .NET Entity Framework?

Using the designer in Visual Studio, how can you define an entity that maps to 2 or more tables? ...

How to prevent private properties in .NET entities from being exposed as public via services?

I'm creating a WCF service that transfers entity objects created via entity framework. I have a User entity that maps to a User db table. There are certain User fields (Password, DateCreated, etc) that I don't want to expose to the client but, because they are non-nullable in the db, Visual Studio requires mappings. Setting these prop...

How to map 2+ entities to same table in .NET Entity Framework?

I'm trying to create 2 entities that operate as different views on the same underlying db table. When I create these in Visual Studio's entity model and place an association between them, I get a "Association is not mapped" error. I read an article (http://blogs.msdn.com/adonet/archive/2008/12/05/table-splitting-mapping-multiple-entity...

ADO.NET Entity Framework: Update Wizard will not add tables

I added a new ADO.Net Entity Data Model into my project and used the Update Wizard to add tables into the model. Five of the selected tables were added to the design surface. Two other tables will not add. I select them in the wizard and click Finish, yet they never show up on the design surface. Is this a bug, or are there some situ...

MVC + Entities Framework: Many to Many relationships

Hi folks Im new to MVC and EF. I have a basic app that lists info from a few (4) tables relating to some servers. One of the relationships is a many to many (Servers to Roles). I pass my ViewData to the View by making use of this in the controller: ViewData.Model = (from s in _db.Servers.Include("Locations").Include("OperatingSystems"...

Can Persistence Ignorance Scale?

I've been having a brief look at NHibernate and Linq2Sql. I'm also intending to have a peek at Entity Framework. The question that gets raised, when I talk of these ORM's is "They can't scale", so can they? From Google I get the impression they're able to scale well, but ultimately I suppose there must be a price to pay, Is it worth pay...

Stored procedures with ADO.NET Entity Framework

I'm trying to use a stored procedure in the entity framework. I had the model created initially without the stored proc. I then went into Update Model from Database and selected the stored procedure I wanted and then added it through the function import. Now I can see the function in the model browser under Function Imports but when I t...

Why is my Linq to Entities code duplicating rows?

I'm using the ADO.NET Entity Framework to manage a hierarchy of objects. Each has a single parent and zero or more children. I present these in my WPF application with a TreeView control. New Things may be added as children to the selected Things with the click of a button... Visual Basic... Private Sub ButtonAddThing_Click(...) ...

What are good design practices when working with Entity Framework

This will apply mostly for an asp.net application where the data is not accessed via soa. Meaning that you get access to the objects loaded from the framework, not Transfer Objects, although some recommendation still apply. This is a community post, so please add to it as you see fit. Applies to: Entity Framework 1.0 shipped with Visu...

.NET Entity framework project layout (architecture)

I'm trying to determine how best to architect a .NET Entity Framework project to achieve a nice layered approach. So far I've tried it out in a browse-based game where the players own and operate planets. Here's how I've got it: Web Site This contains all the front end. C# Project - MLS.Game.Data This contains the EDMX file with all...

ASP.Net Entity Framework

I'm just trying the ASP.Net Entity framework its the first time I've tried to use an ORM framework so bear with me If I'm barking up the wrong tree. To simplify the problem I've got the following 2 tables Calendar CalendarID UserID Date EventName Users UserId Username I've added them both to my Entity Framework model and its establ...

Why does a simple entity data model relationship return null instead of a reference to an object?

I have 2 simple tables and a foreign key defined in SQL Server Express: Product ProductID [auto-inc] Name CompanyID [not-null] Company CompanyID [auto-inc] Name FK_Product_Company Product.CompanyID = Company.CompanyID I created an ADO.NET Entity Data Model and added all the tables to it. The .edmx file shows the 1-to-ma...

ASP.Net Entity Framework Model

Is it possible to add properties to my model that dont exist in the database? For example I have a calendar table, I want to retireve this data in my MVC controller then work out time left until each entry starts and return this to the view. So I would like another property in my calendar model to hold time left which is a value that I ...

Entity Framework + SQLite deployment

Hi, I have a ASP.NET MVC app that is using SQLite database through Entity Framework. Everything works on VS 2008's local development webserver. However, deploying the web app to my service provider causes this error: [ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.] System.Dat...

Entity framework and many to many queries unusable?

I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole table. EDIT: Tables: Person (personid, name) Personlocation (personid, locationid) Location (locationid, description) Personrole (per...