entity-framework-4

What causes POCO proxy entities to only sometimes be created in Entity Framework 4.

I have set up my POCOs and I have marked their public properties as virtual and I am successfully getting Proxies most of the time (95%) but randomly I am getting EF return some proxies and some non-proxies. Recycling the app pool when this happens will then fix this instance of the error and it will go away for an amount of time. Then ...

EF4 is throwing an error "Schema specified is not valid"

I'm getting a weird EF4 "Entity Framework v4" error when I do a select on the context. There I get is: Schema specified is not valid. Errors: The relationship 'AnalyzerConfigurationModel.FK_AnalyzerMetadataParameters_AnalyzerMetadata' was not loaded because the type 'AnalyzerConfigurationModel.AnalyzerMetadataParameter' is not availab...

Entity Framework POCO objects

I'm struggling with understanding Entity Framework and POCO objects. Here's what I'm trying to achieve. 1) Separate the DAL from the Business Layer by having my business layer use an interface to my DAL. Maybe use Unity to create my context. 2) Use Entity Framework inside my DAL. I have a Domain model with objects that reside in my ...

Entity Framework 4 "Generate Database from Model" to SQLEXPRESS mdf results in "Could not locate entry in sysdatabases for database"

I'm using Visual Studio 2010 RTM. I want to do model-first, so I started a new MVC app and added a new blank edmx. Created a few entities. No problem. Then I "Generate Database from Model", and allow the dialog to create a new database for me, which it does successfully as 'mydatabase.mdf' in the app's App_Data directory. Then I open th...

EF4 querying from parent to grandchildren

I have a model withs Parents, Children and Grandchildren, in a many-to-many relationship. Using this article I created POCO classes that work fine, except for one thing I can't yet figure out. When I query the Parents or Children directly using LINQ, the SQL reflects the LINQ query (a .Count() executes a COUNT in the database and so on)...

does Entity framework support user defined functions as scalar properties

I would like to include the value of a scalar function as a read-only property of an entity, since that I could include that value in a filter, is such a thing possible? ...

Maintaining state and data context between requests in ASP.NET + EF4

I have a EF4/ASP.NET web application that is structured to use POCOs and generic repositories, based essentially on this excellent article. The application is relatively sophisticated with one page that involves selection and linking of multiple entities to build up a complex user profile. This requires access to multiple entity types (...

Dynamic Data - Make Friendly Column Names?

I've created a Dynamic Data project with an Entity Framework model. It works nicely. But, right now it shows all my database tables with the db column names - which aren't always the most friendly (e.g. address_line_1). How can I got about giving these more friendly column titles that will display to the end user? ...

Will .net 4.0 runtime work with SQL Server 2000?

According to this article, Visual Studio 2010 no longer supports SQL Server 2000. However, it's a bit less clear on whether the runtime (and things like ASP.net 4.0, Linq2SQL and EF) will work with it. It seems that only the design-time features require SQL Server 2005 or greater according to that article. I have a project that requir...

EF4 Generic Search by ID

I have x number of tables and all tables have a uniqueidentifier/guid primary key. I want to write a generic function that will take a Guid param id where T is EntityObject like so... public T SelectById<T>(Guid id) where T : EntityObject It seems like this would be a simple thing to do. I've scoured the internet and can't quite find ...

For Entity Framework associations, are Independent Associations or FK Associations recommended?

For Entity Framework associations, are Independent Associations or FK Associations recommended? I have been receiving an error with the multiplicity I tried to use in an independent association. ...

Entity Framework : updating one-many relationships for an entity's child collection

Consider an application dealing with houses and pictures. An entity named House has a 1:n relationship to HousePicture. The application allows the user to create and edit a House, and add/remove HousePictures. [HttpPost] public ActionMethod Edit(House h) { //get an attached entity from the DB first. House original = db.Houses.Sin...

AD0.NET Entity Framework 4.0 or Linq-to-SQL.

hello, I am developing a application with asp.net 4.0. My site will be a heavy like more then hundreds of user will be online at a time and lots of content will be there. I have checked both ado.net entity framework 4.0 and Linq-To-SQL with Microsoft.NET Framework 4.0 both are having great improvement over there. I am confused that whic...

EF 4.0 Dynamic Proxies POCO Object Does not match target type.

I am using EF 4.0 and POCO's. I stumbled across this error while inserting to records into the data base. Property accessor 'QualityReasonID' on object 'BI.Entities.QualityReason' threw the following exception:'Object does not match target type.' There errors occur on the Databind to a GridView after saving a new record to the databas...

When should POCO be used in EF4?

We have an ASP.Net MVC2 web site, and are utilizing EF4 for database access, etc. Being new to EF4, we have come across the EF4 POCO concept, however do not fully understand it. In general, I've heard POCO defined as objects "not dependent on an external framework". In the case of EF4, I'm guessing this means that POCO would imply som...

Cannot delete entity with ComplexType property (Entity Framework 4)

Hi everyone, This has been driving me nuts for a week now. I have a class that looks like this: public class SuggestionVote { public virtual int ID { get; set; } public virtual Suggestion Suggestion { get; set; } public virtual User User { get; set; } public virtual VoteTypeWrapper VoteType { get; set; } public virtual ...

Entity Framework 4 - How work around to use cast with interfaces

How can I use cast in Linq to Entities? I need something like this: if (typeof(myObject) is IMyInterface) { return MyObjectSet.Where(x => ((IMyInterface)x).MyProperty == 1); } If I try above code, I get an exception. It's an expected behavior of EF or it's a bug? ...

Using "custom data types" with entity framework

I'd like to know if it is possible to map some database columns to a custom data type (a custom class) instead of the basic data types like string, int, and so on. I'll try to explain it better with a concrete example: Lets say I have a table where one column contains (text) data in a special format (e.g a number followed by a separator...

Entity Framework Code Only Relationship Not Being Read

(This looks like a long question, but it's not really, honest!) I am trying to get a simple proof of concept working with Entity Framework 4 and the CTP 3 version of Code Only. It feels like I'm missing something really obvious and simple. I have this following test which is failing: [TestFixture] public class ParentChildTests { [...

How to delete entity in Silverlight 4 using RIA and Entity Framework?

I'm working on a Silverlight 4 app using RIA and entity framework that is connecting to SQl Server 2008. I wrote a service method to delete some entities, I can step into the code and watch it execute on the two entities I expect to delete, but when I submitchanges the records don't delete. I'm using a DomainContext to excute the ...