entity-framework-4

Is there any way to know that an EF4 entity is rehydrating?

And, if not, what pattern should I use when adding this into the T4 templates? ...

How do I add a RowVersion attribute to a EF4 class

I am using EF4 and creating classes through the Entity design surface then generating the database from them. I want to add an attribute to some of the classes to show the timestamp they were last updated. I have added a Version attribute to them, but I don't know which .Net datatype to associate with them so they become either Timesta...

EF4 LINQ Include(string) alternative to hard-coded string?

Is there any alternative to this: Organizations.Include("Assets").Where(o => o.Id == id).Single() I would like to see something like: Organizations.Include(o => o.Assets).Where(o => o.Id == id).Single() to avoid the hard-coded string "Assets". ...

Map a column to be IDENTITY in db with EF4 Code-Only

Although I have marked my ID column with .Identity(), the generated database schema doesn't have IDENTITY set to true, which gives me problems when I'm adding records. If I manually edit the database schema (in SQL Management Studio) to have the Id column marked IDENTITY, everything works as I want it - I just can't make EF do that by it...

How do I verify my EF4 Code-Only mappings?

In NHibernate, there is a method doing something like ThisOrThat.VeryfyMappings() (I don't know the exact definition of it since it was a while ago I last tried NHibernate...) I recall seeing a blog post somewhere where the author showed how to do some similar testing in Entity Framework 4, but now I cant find it. So, how do I test my E...

Unique keys in Entity Framework 4

An existing DB schema has unique, non-primary, keys, and some foreign keys that rely on them. Is it possible to define unique keys, which are not primary keys, in Entity Framework v4? How? ...

Entity Framework 4 website architecture

Hi I've been given the task of creating an N-Teir website using the Entity Framework 4 and am coming up against some brick walls, more than likely in my knowledge. My plan so far was to have these layers Website (application layer), What I'm calling Name.Framework (BLL), Name.Data (DAL), Name.Entities (contains POCO classes and other s...

EF 4.0 and Visual Studio 2008

Can I use EF4.0 relased with .NET framework 4.0 with VS2008? ...

Custom DDL Templates for Visual Studio 2010

I was wondering if anyone knows of some good community distributed custom DDL templates for Entity Framework 4.0. The default DDL to SQL10 Works well enough, but we're looking to do some customization to the naming convention that it just isn't offering us. I'm not really finding many samples out there of people doing this, so I was ho...

Tracking changes in Entity Framework 4.0 using POCO Dynamic Proxies across multiple data contexts.

I started messing with EF 4.0 because I am curious about the POCO possibilities... I wanted to simulate disconnected web environment and wrote the following code to simulate this: Save a test object in the database. Retrieve the test object Dispose of the DataContext associated with the test object I used to retrieve it Update the test...

Generate EF4 POCO classes first time only

The problem I'm having is, using the POCO templates, generating my POCO classes the first time only and not overwriting them when the templates are re-ran. I know this sounds hokey and the reason is that I'm actually changing these templates and trying to generate metadata classes rather than the actual POCO classes, but these metadata c...

IObjectSet Include Extension Method Errors with CompiledQuery

In my Custom ObjectContext class I have my entity collections exposed as IObjectSet so they can be unit-tested. I have run into a problem when I use this ObjectContext in a compiled query and call the "Include" extension method (From Julie Lerman's blog http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-5-i...

Entity framework 4 and multiple database.

Something changes or it still not support this? For example join database1.dbo.Users and database2.dbo.Addresses ...

What are the major limitations of EF4?

Hi, I am trying to decide on an ORM tool for my project, and I am thinking about EF4. What are the major (if any) annoyances/limitations with this product? Also, does it support caching? Thanks ...

Partial mapping in Entity Framework 4

Hi guys, I want to be able to do the following: I have a model and inside there I do have an entity. This entity has the following structure: public class Client { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } } What I want now, is to just get the client name bas...

Benefits of EF4 in a POCO architecture

During DevConnections I veered off the Silverlight track and stumbled into an awesome talk by Chris Sells about EF4. I was really impressed by what is possible now vs 3.5 SP1. At the same time, I'm wondering what benefit there would be in taking a system that is a heavy POCO architecture and inserting EF4 in the mix. Change tracking? LIN...

How to rollback in EF4 for Unit Test TearDown?

In my research about rolling back transactions in EF4, it seems everybody refers to this blog post or offers a similar explanation. In my scenario, I'm wanting to do this in a unit testing scenario where I want to rollback practically everything I do within my unit testing context to keep from updating the data in the database (yeah, we'...

Entity Framework - Using a list as a paramater in a compiled query

Hi guys Just wondering if anyone knows whether I should be able to pass in list into a compiled query and have the query perform a contains operation? The reason why I ask is that I have a scenario where I need to do this, yet at run time I am getting the following error... The specified parameter 'categories' of type 'System.Collect...

Explain Entity Framework 4's connection strings

I created an Entity Framework file. My database is called MyDB. My Entity Framework file is MyDB.edmx and I used an existing connection string (MyDBConnectionString) to generate the edmx model. It created two more connection strings: MyDBEntities MyDBContainer What are these for? They look exactly the same and both have the informat...

How to auto-generate simple CRUD controllers and views in ASP.Net MVC 2 (VS2010) Entity Framework project?

I have a standard template "ASP.NET MVC 2 Web application" solution, an empty (meaning no data inserted, but with all tables etc. ready and waiting) SQL Server database, an Entity Framework 4 model (edmx). Is there a way to generate simple CRUD controllers and form views for all the entities in the model? ...