entity-framework

How about performance of linq to sql, Entity Framework and NHibernate?

I was learning this ORM because think this is good technology for most projects. But most employers required acquirement of ADO.NET and SQL. This ORM not will use in high-loaded system (like popular web-sites)? In which types of projects this ORM will be useful? Are highly loaded projects using ORM? ...

How to organize asp.net mvc project (using entity framework) and a corresponding database project?

I recently switched to vs2010 and am experimenting with asp.net MVC2. I am building a simple website and use the entity framework to design the data model. From the .edmx file, I generate the database tables. After a few iterations, I decided that it would be nice to have version control of the database schema as well, and therefore I a...

Entityframework 4.0 .CreateQuery<T> and OrderBy exception

Hi Guys, I thought this was fixed in 4.0. I have this method public IQueryable<T> All(Expression<Func<T,object>> sort) { return EntityContext.CreateQuery<T>(EntityName).AsQueryable<T>().OrderBy(sort); } this throws the following exception Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to E...

Mapping and metadata information could not be found for EntityType Exception

I am trying out ASP.NET MVC Framework 2 with the Microsoft Entity Framework and when I try and save new records I get this error: Mapping and metadata information could not be found for EntityType 'WebUI.Controllers.PersonViewModel' My Entity Framework container stores records of type Person and my view is strongly typed with class Pe...

binding between EntityFramework Objects and WebForm Controls

With ASP.Net 4, is there any way that we can bind web-form controls to entity framework objects? <asp:TextBox ID="UserName" runat="server" BoundTo="UserName" BindingSource="..."></asp:TextBox> so just like in MVC I can form.UpdateModel(userObj), form.DisplayModel(userObj) any ideas? ...

Detecting orphaned records with Entity Framework

I'm wondering if there is a better way to clean up orphaned records using ASP.NET and the entity framework. For my example there are three objects: Persons, PhoneNumbers and Emails. PhoneNumbers and Emails can be associated with multiple people (ie [email protected] could go to multiple people). I want to make sure there are no o...

EntityFramework: Access dabase-column using user defined Type

I "inherited" an old Database where dates are stored as Int32 values (times too, but dates shall suffice for this example) i.e. 20090101 for Jan. 1st 2009. I can not change the schema of this database because it is still accessed by the old programs. However I want to write a new program using EF as the O/R-M. Now I'd love to have DateTi...

Data Access example using Entity Framework

Does anyone know of or having any good examples of how to use Entity Framework version 2 in the Data Access layer and put an interface on it so the business layer uses the interface rather than knowing about EF? I have found some examples but they are all from 2009 and I'm not sure how they relate to Entity Framework version 2. ...

Entity Framework - Nullable Foreign Key error - "Problem in mapping fragments..."

Hey, I have a Website table that has a foreign key to a Client table. A Website isn't always going to have an associated Client but when I save a Website without specifying a client then it errors out, as Website.ClientID is an int32 (not nullable) and is set to 0. I tried changing the relationship in my EF diagram to be a * next to Web...

Entity Framework - Null foreign key reference doesn't get updated in database

Hey all, I have a Website entity that has a foreign key to a Client entity. If I first set the Website.ClientID to something and save it, then change the Website.ClientID (or the Website.ClientReference) to null, when I do SaveChanges it updates every other property except ClientID, so I can't "clear out" the Client from the Website. Ho...

Can I clone an IQueryable in linq? For UNION purposes?

I have a table of WorkOrders. The table has a PrimaryWorker & PrimaryPay field. It also has a SecondaryWorker & SecondaryPay field (which can be null). I wish to run 2 very similar queries & union them so that it will return a Worker Field & Pay field. So if a single WorkOrder record had both the PrimaryWorker and SecondaryWorker field...

Using ADO.NET Entities LINQ Provider to model complex SQL Queries?

What I find really powerful in ADO.NET Entities or LINQ to SQL, is the ability to model complex queries. I really don't need the mappings that Entities or LINQ to SQL are doing for me - I just need the ability to model complex expressions that can be translated into T-SQL. My question is - am I abusing too much? Can I use the Entity Fra...

Foreign key relationships in Entity Framework v.1

I need to be to create an entity data model in the EF version 1, because my web host doesn't have Framework 4.0 yet. Below is just a simple example to show the problem. I have 3 tables, one Users table, another Webpages table, and one table with Visits. The former two tables each have a one-to-many relationship with the Visits table (w...

Get data on the basis of conditions in entity framework 3.5 with include

Hello All: I am using entity framework 3.5 for my application. I want load data based on some condition e.g. var data = from e in context.Employee.Include("Employee.Projects") where e.IsActive select e; Using this, I will get all the Employees which are active with their project details. But I want to load only those projects which ...

Additional parameters in mapped insert procedure - Entity Framework

Hi, I'm using Entity Framework with stored procedures mapped to insert, update and delete operations. My problem is that for example the insert procedure accepts not only columns of the entity but also additional column which is only needed for the insert procedure do it's logic. I've tried adding property to the model via VisualStudio ...

entity framework join

Hi, i have 2 table (user, user_profile) without a explicit relationship in the sql db. and i can't add it to the db. so, i can't do this: db.user.include("user_profile") the attribute in for the join is user_id is possible do anything like this? db.user.join("user_profile On user.id = user_profile.user_id") How can i do that? th...

problem with contains in objectquery

This code give me an error: string rus = "," + db_user.Anagrafica_Dipendente.ID_Dipendente + ","; int i = db.CBR_User.Count( p => p.RiceviMail == true && ("," + p.Dipe + ",").Contains(rus)) p.Dipe is a string the error is: Unable to create a constant value of type 'System.Object'. Only primitive types ('such as Int32, String, an...

asp.net listview showing data from related entity and changing it

Hello, I am using entity framework. My model has entity tblGameInfo where in navigation properties are associations called tblPlayer1 and tblPlayer2 which links to entity tblPlayer. I have listview on my page where I want to show game info with players names. I have found that in of listview I should have e.g. one of those: ...

Is there an equivalent to odata's QueryInterceptor in the Entity Framework?

Hi, I'm looking for the simplest way to implement row-level authorization in Entity Framework 4. Something like odata's query / change interceptors would be great. This two-year-old msdn forum thread mentions that it was on the team's to-do list at that time. Has this been implemented by now? I could not find anything anything related...

Share edmx Betwen .NET projects and C# Class Library

Hi there, I had two seperated projects that used the same database, similar methods, etc. So i've created a new solution and added those two projects. I've created an C# Class Library project and i've writed there all the methods from the other two. I've also created an edmx file for DAL layer. I've added the reference of the C# Class ...