entity-framework

Database and EF performance concern?

I have a basically sql select question that people gave me different answers over the years. Say I have a couple of tables designed each with over 40 columns and potentially will hold ten and thousands of row, I'm using SqlServer2005. On joining these tables, in the where clause if I have things like select * from t1, t2 where t1.User...

Linq to Entities / Entity Framework cross edmx "join"

I have two entities, each from a different database and therefore different edmx files. There is, however, an infered relationship between them. Foo has many Bars for example. What's the easiest way to do this join in the EntityFramework, with fewest database calls? Thanks. ...

Using entity framework, should I add a timestamp to all my database tables?

I'm planning to use MS entity framework for new web apps (come on EF v2!). So does it make sense to plan ahead by adding timestamp columns to all entity tables in existing and future databases, to support concurrency checks? Is there any reason why it would be a bad idea to have a timestamp column in every table? Note that the point is...

Entity Framework - associated entities question

I've noticed that if i have an Pk/FK association, the FK ID is removed from the entity in the designer. How do I join query statements? Basically I'm looking for some good Linq to Entity video tutorials (sorry, I'm an audio/visual learner) ...

Entity Framework - how do I use the entity associations?

When I have tables in my database that have PK/FK relationships (int) and when they are modeled by the Entity Framework designer everything seems as it should be. I can write the code below and everything seems like it's going to work fine as well but then when I run the code I get an error on the project.Status.StatusName saying the Ob...

Entity Framework - how do I use the entity relationships in my extended classes?

I am trying to extend the partial classes that the entity framework creates so that I can more easily work with objects like in the code below (please let me know if there's a better or more exceptable way of doing this with the entity framework) Public Sub New(ByVal ProjectID As Integer) Dim proj As Project = (From p In db....

Adding to the Where clause of an Update in LinQ-to-Entities

Let's say I have a table called Product, with three columns: Id, CustomerId, Name. Id is the primary key. The schema is outside of the control of my group, and we now have a requirement to always provide CustomerId as a parameter for all queries (selects, updates, deletes). It's a long story I'd rather not get into ... it involves trig...

Best Entity framework documentation?

Where is the best documentation to learn how to read this line? The MSDN reference pages are extremely terse as usual. What is the effect of adding Include("Course")? What does "it" mean in "it.Name"? Why wouldn't you specify just "Name"? ObjectQuery departmentQuery = schoolContext.Department.Include("Course").OrderBy("it.Name"); ...

Entity Framework: Working with detached objects and attached ones

Firstly, let me set out what I'd like to do. Assume I have three types of EntityObject, MetaData, Data1 and Data2. MetaData is, as one would expect, has a reference to one instance each of Data1 and Data2. Now, for each MetaData, I can calculate a value. So far so simple. Now, I would like the user to play around with various combinatio...

Looking for Specific Date

Anyone know how to query for a specific date within entity framework ? I tried following code, but it gives me NotSupportedException. var deposit = (from tempDeposit in entities.Deposit where !tempDeposit.IsApproved && tempDeposit.CreatedDate.Date == DateTime.Today select tempDeposit).FirstOrDefault(); I also tried following code but ...

ADO.NET Entity Framework and Linq to Entities

I'm confused about Linq to Entities. Is it the new name of Entity Framework or are they different things? ...

Problem with Entity Framework Model Designer and SQL_Variant datatype

I have a table that has a column with SQL_Variant type and some other columns with types like int, bigint,... When I add this table to edmx file it adds all columns but the SQL_Variant typed column. Is there a bug or I have to do something to add that column? ...

Flexible design - customizable entity model, UI and workflow

Hi All, I want to achieve the following aspects in the software I am building: 1. Customizable entity model 2. Customizable UI 3. Customizable workflow I have thought about an approach to achieve this, I want you to review this and make suggestions: Entity objects should be plain objects and will hold just data Separate Entity model ...

Entity Framework Mapping, different property name

Hi, I have a database field called abCode, that I want to map to a property called statusCode in the objectlayer. What changes are needed to the msl, csdl, ssdl and object layer to acomplish this? Here are the relevent (I think) parts of the files: In msl: <ScalarProperty Name="abCode" ColumnName="abCode" /> In csdl: <Property Nam...

Databinding ASP.net DropDownList with Entity Framework

I'm trying to bind an ASP.net DropDownList to the results of an entity framework query, while still maintaining multi-tier separation. (i.e. I don't want my UI code to contain query details, nor my Data Layer code to have UI dependencies.) My code-behind in the Page_Load event handler looks like this: IEnumerable<Lookup> Types...

Using the entity framework to add existing entities to a collection on a newly created entity.

I am using the Entity framework to create a new order. The order contains a collection of contacts, a many to many relationship. I want to add a reference to an existing contact on the order on creation of the order. Both Order and Contact a Entity Objects. Order order = new Order(); //set details on order Contact contact = new ...

EF entites via WCF problem

I've created a WCF service based on an Entity Framework model. When I consume the service from a console app, a WinForm app, and a WPF app, everything just works. I can see the entites and can add/delete/etc. However, when I try to consume the same WCF service from a web app, I get errors stating that the entities are not recognized. ...

How to mock ObjectContext or ObjectQuery<T> in Entity Framework?

How to mock ObjectContext or ObjectQuery in Entity Framework? ...

Join and Include in Entity Framework

I have the following query in linq to entities. The problem is that i doesn't seems to load the "Tags" relation even thou i have a include thingy for it. It works fine if i do not join on tags but i need to do that. var items = from i in db.Items.Include("Tags") from t in i.Tags ...

What is the best way to build a data layer across multiple databases?

First a bit about the environment: We use a program called Clearview to manage service relationships with our customers, including call center and field service work. In order to better support clients and our field technicians we also developed a web site to provide access to the service records in Clearview and reporting. Over time ...