entity-framework

Comparing Date / DateTime ine Entity SQL Where clause...

I have a method which accepts an ObjectQuery and adds Where clauses to it depending on whether it receives values for various filter parameters. The method has to return an ObjectQuery. How can i do a basic Date comparison e.g. where dateX < dateY. This is my current code: if (myDateFilter != null) { query = query.Where( st...

Entity framework PostgreSQL

Hi. Can someone tell me how can I get MS Entity Framework working with PostgreSQL. How does Entity Framewok work with Mono? Could you please suggest other similar ORM tools which would run on Mono and what is your opinion about them? ...

Entity Framework - Detaching and Re-attaching entities?

I have Entity-Attribute-Value (EAV) database. Entity in this sense has nothing to do with entities in EF but merely refers to some "thing" about which you are storing information. You store a value in the Value table, which is associated with an Attribute (the name of the information) and an Entity. In the EAV model, you don't store NUL...

ASP.NET MVC - model decision: how to design it?

This is concerning an enterprise application with a very generic database (all objects are identified using data in the database and internationalized/globalized/localized). Make a model for Repository pattern, then make (generate 1:1) another model for DB access (LINQ2SQL or EF) and use the later as repository model data access layer?...

Should I read a book on specifically SQL Server, ADO, ADO.NET or ADO.NET Entities to learn to persist data for an ASP.NET MVC app?

I know the basics of mySQL and database normalization. I am getting into Microsoft programming now and plan to do a large website using ASP.NET MVC. The level of complexity of the website is probably similar to StackOverflow and other database-intensive websites. Except mine won't expect so many visitors of course :) I hear Entities is...

Entity Framework Delete Object Problem

hi, i am getting "The object cannot be deleted because it was not found in the ObjectStateManager". while Deleting object. here is codes ; //first i am filling listview control. private void Form1_Load(object sender, EventArgs e) { FirebirdEntity asa = new FirebirdEntity(); ObjectQuery<NEW_TABLE> sorgu = asa.NEW_T...

LINQ to Entity Framwork: return sorted list of related rows

Table Category (c) has a 1:many relationship with Table Question: a Category can have many Questions but a Question belongs only to one category. The questions are also ranked in terms of difficulty. I would like a LINQ to EF query that would return all Categories with related Questions but the Questions should be sorted ascending ...

ADO.NET Entity Association problem

hi , i got Two Table named Personel and Departmant.. Personel Table ; PERSONELID int , PK not null NAME varchar SURNAME varchar DepartmanID integer Departman Table ; DepartmanID int , PK not null DEPARTMANNAME varchar (ONE TO MANY Relation) i wanna association between this tables. but i cant do it. with EDMX Model Designer .. gett...

How can I get the current user equivalent to an aspnet_User object?

My table, AccLink, has a foreign key, UserId, to the aspnet_User table created by the Membership Provider. When creating an object of type AccLink (I'm using the entity framework) I need to assign the aspnet_User by getting the current user object. I tried Membership.GetUser(userName) but it said it couldn't be converted to type aspnet...

Problem with adding MS-SQL view in Entity Data Model

Hi All, I have a problem with adding a MS-SQL view to my Entity Data Model. The view is so simple and I added the table related with this view. Below T-SQL script about view. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER VIEW [dbo].[HFL_VWPrcListSrchRslt] AS SELECT sfiyat_fiyati, sfiyat_stokkod FROM STOK_SATIS_...

Optimistic concurrency in ADO.NET Entity Framework

I found an MSDN article that describes how EF handles concurrency when saving changes: By default [...] Object Services saves object changes to the database without checking for concurrency. For properties that might experience a high degree of concurrency, we recommend that the entity property be defined in the conceptua...

Patterns for using EntityFramework ?

What is alternative patterns of using for Entity Framework ? Some I know are: "Plain" EntityFramework - aka Unity of Work using (Data.Model c = new Data.Model()) { var z = c.Users.Where(x=>x.Name=='John'); } Repository pattern //Model implements IRepository User user = Model.Instance.Get<User>(u => u.Name == "John"); What else...

Problem with Entity Framework after adding column to DB table

I needed to add a new NVARCHAR column to a table in my DB. So I added the column, and then fired up Visual Studio to update the EDMX-file for the Entity Framework. I ran update model from database on everything, which only resulted in "data reader is incompatible"-errors. So I renamed the whole table in the DB, updated EDMX from databas...

How to optimize Entity Framework Queries

I am using Linq-To-Entities to do a query which is returning only 947 rows but taking 18 seconds to run. I have done a "ToTraceString" to get the underlying sql out and ran the same thing directly on the database and get the same timing. I have used the tuning advisor and created a couple of indexes although with little impact. Lookin...

EFPocoAdapter use

Hello after much debating between nhibernate and EF, our team has decided to go for EntityFramework with EFPoocoAdapter to solve the POCO problem with EF. Wondering if there are projects (> 400 db tables) being developed using this adapter, and if there are things that we should be aware of while using it. many thanks ...

Views and Entity Framework

I've created a view in my database which I would like to include in my entity model. However, when I try to update the entity model through VS 2008, a warning message informs me that the TABLE OR VIEW I'm trying to add doesn't have a primary key. It seems that in order to add a view to the model, this must have a key field! How can I a...

Entity Framework - strange issue with multiple foreign keys mapped to the same table

Hi All, I am using EF (Framework 3.5 SP1) and have a simple two table demo set up: Applicants applicant-id int applicant-pref-lang-coorepondence int (FK to CodeLanguages) applicant-pref-lang-exam int (FK to CodeLanguages) applicant-pref-lang-interview int (FK to CodeLanguages) CodeLanguages code-lang-id int code-lang-desc varcha...

Changing a relationship / foreign key in Entity Framework - not being persisted

Hey there, Ive got a WPF app, following the Model View ViewModel pattern, using the Entity Framework to interact with a SQL 2008 database. Problem: My problem is i can't change a foreign key value in the databse using EF. I have two entities: Site and Key. A Site can have many Keys on it. I would like to move a Key from one Site to a...

Entity Framework and Temporary Objects

Hello, I'm new to the Entity Framework and am currently experimenting with it. I created a simple database, set up the model in VS2008, and have got the code going to query the database using the EF as well as inserting new data. There's one thing that has me a little confused though. I have an entity (set up in my model) called Custom...

How to write an entity comparator in C# (with example code of first attempt)

Hi All, I want to know the most efficient way of comparing two entities of the same type. One entity is created from an xml file by hand ( ie new instance and manually set properties) and the other is retvied from my object context. I want to know if the property values are the same in each instance. My first thoughts are to generate...