entity-framework

Removing entity bug

hello, I am trying out the ria services and I am experiencing this problem that seems very strange to me. I am creating a new entity of type "House" and add it to context without saving the context so the id of the new entity is 0, after i remove this entity and add another new entity of type "House" again and again without saving the co...

Entity Framework 4 ste delete foreign key relationship

I'm using EF4 and STE w/ Silverlight. I'm having trouble deleting child records from my primary entity. For some reason I can remove child entities if their foreign key to my primary entity is part of their Primary Key. But if it's not, they don't get removed. I believe these posts explains it: http://mocella.blogspot.com/2010/01/enti...

Crazy VS Designer Errors

Here's a strange one. After renaming a class, one of my forms began giving me errors in the designer, refusing to open. Funny thing is, the form worked just fine when I ran the program. I began reverting my changes to deduce the problem. I have now reverted completely back to the last commit - in which I know the form was working in ...

Inefficient 'ANY' LINQ clause

I have a query that pulls back a user's "feed" which is essentially all of their activity. If the user is logged in the query will be filtered so that the feed not only includes all of the specified user's data, but also any of their friends. The database structure includes an Actions table that holds the user that created the action a...

Business entity: private instance VS single instance

Suppose my WinForms application has a business entity Order, the entity is used in multiple views, each view handles a different domain or use-case in the application. As an example, one managing orders, the other one digging into one order and displaying additional data. If I'd use nHibernate (or any other ORM) and use one session/data...

generate EF model by System.Diagnostics.Process

Hello, after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess = new Process(); var cs = "Data Source=.\\SQLEXPRESS; Initial Catalog=uqs; Integrated Security=SSPI"; myProcess.StartInfo.FileName = @"C:\Windows\Microsoft.NET\Framework\v3.5\EdmGen.exe"; myProcess.StartInfo.Arguments = ...

error 2016: Condition cannot be specified for Column member

I am having some issues with Entity Framework in VS2010 The problem I'm getting is described very well here... http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/cacf6a76-09a8-4c90-9502-d8b87c2f6bea It's basically happening when a Foreign key is pointed at the primary key of another table...but if I take off the StoreGenerate...

Linq to Entities Join -- I don't want anonymous types

I have two tables ('keywords', 'titles') that are related via a mapping table. I am trying to return a list of Map_Keywords_Title (the mapping table's object) based on the results of a join. Until I added the last part with typedQuery it was just returning objects of anonymous type. I want it to return items of type 'Map_Keywords_Title...

Entity Framework - Why does EF use LEFT OUTER JOIN's in a 1-to-1 relationship?

Why does .NET Entity Framework produce SQL that uses a subquery and left outer join on a simple 1-to-1 relationship? I expected to see a simple join on the two tables. I'm using Devart Dotconnect for Oracle. Any ideas? Below is the output I see courtesy of the EFTracingProvider: SELECT 1 AS C1, "Join1".USER_ID1 AS USER_ID, ... FROM "M...

Entity framework (3.5): How to translate a certain LINQ query to eSQL?

Hi there, I have the following LINQ query that I need to translate to Entity SQL /eSQL): return (ObjectQuery<User>) from user in Users where !user.Roles.Any(r => r.AnIntegerProperty < 0) select user; User.Roles is an navigation property to the n:m relation to Roles and there also is a Role.Users navigation property the other wa...

Closing an EDM ObjectContext?

I am getting started with the ADO.NET Entity Framework 4.0. I have created an EDM and data store for the app, and it successfully retrieves entities. The application holds the EDM's ObjectContext as a member-level variable, which it uses to call ObjectContext.SaveChanges(). So far, so good. I am going to refactor to repositories later. ...

Entity Framework - fields are missing in the table in my Data Model

Hi, I'm relatively new to this stuff. I created a .Net Entity Data Model, but three fields are missing in one of the tables. I tried creating a new one from scratch, etc. I can see those fields in the Model Browser(when I expand Tables/Views => tablename), but not in the DataModel.edmx itself. I'm using SQL DB. Why can this be happe...

Random sort list with LINQ and Entity Framework in vb.net

I've seen many examples in LINQ but i'm not able to reproduce the same result in vb.net. I have following code: Dim context As New MyModel.Entities() Dim rnd As New System.Random() Dim gardens As List(Of Tuin) = (From t In context.Gardens Where _ t.Approved = True And _ ...

Generate POCO classes in different project to the project with Entity Framework model

I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects fo...

How to clean-up an Entity Framework object context?

I am adding several entities to an object context. try { forach (var document in documents) { this.Validate(document); // May throw a ValidationException. this.objectContext.AddToDocuments(document); } this.objectContext.SaveChanges(); } catch { // How to clean-up the object context here? throw...

SQL Server "User-Schema Separation" and Entity Framework issues

I have been fooling around with EF with a database that has implemented user-schema separation with a twist, there are multiple tables with the same name but are separated via the schema. So like: admin.tasks staff.tasks contractor.tasks When I created my EF model I noticed that there were 3 tasks tables: tasks tasks1 tasks2 Is this...

Defaulting scope in entity framework

Is there a way to default the scope to internal with updating an .edmx from a database? I get tired of having to go through large tables setting every getter, setter, etc. to internal instead of public ...

Entity Framework: Delete Object and its related entities

Hi, Does anyone know how to delete an object and all of it's related entities. For example i have tables, Products, Category, ProductCategory and productDetails, the productCategory is joining table of both Product and Category. I have red from http://msdn.microsoft.com/en-us/library/bb738580.aspx that Deleting the parent object also d...

Class for DB access via an Entity Model, how to cleanup the connection?

I have a class I'm using to handle all my DB interaction. Basically when an instance of this class is created it creates an instance of the model, which will persist until the DataAccess object is out of scope. public class DataAccess { ModelContainer model; public DataAccess() { model = new ModelContainer(); }...

What's the best way of delivering EF models over WCF?

I've got new project on the go and I'm looking at using the Entity Framework (v4) over a WCF service. I was wondering what peoples views are on the best way of delivering the data from EF over WCF? Should I be using the EF generated classes or wrap them up into something else? The consuming application will be web for the moment, but p...