entity-framework-4

Asp.Net mvc 2 , DropDownListFor and Editor Template . Selected Value dosen't work

I Have 2 views. ProductForm.aspx and Category.ascx. CategoryForm is a Partial View. I Call the Category.ascx from the ProductForm with EditorFor(model => model.Category) . In this partial view, there is a DropdownlistFor with all the category. The problem is the Selected Value for a specific Product Category. The selected value dosen't w...

EF4 TPT insert inherited table

Supposing my Application consumes two tables represented as two entities: Person and Employee. And: I am not allowed to make changes in table person. (I suggest get data from a view) Employee must inherit from Person. I am trying to implement Table-Per-Type inheritance, but I don't know how to insert rows in table Employee. Employ...

RIA Services: Entity Framework Reference Entities

I'm attempting to use RIA services with a Entity Framework back end. The Model was auto generated by the designer. (VS 2010, .NET 4.0, EF 4.0, SilverLight 4.0) The issue that I'm running into is that Reference Properties are being loaded as expected at the Service Layer, but when that information is passed over to the SilverLight App the...

Specifying a unicode-named column in dynamic where clause (Entity Framework)

Hi, When I set where clause of a EntityDataSource which contains a unicode column name, this exception occurs: The simple identifier 'عنوان_قرارداد' must contain basic Latin characters only. To use UNICODE characters, use an escaped identifier. Near line 6, column 4. and this is a part of my code: GridDataSource.Where = "...

Entity Framework issue - "Mixed mode assembly...cannot be loaded in the 4.0 runtime without additional configuration information"

I have a UI & Library project for the solution where I'm having the problem. The library project uses Entity Framework & the unit tests work OK with it. The project is a C# 4.0 WPF application. To try to get a basic EF line of code working I copied the connection string from the Library project app.config to the UI project app.config....

Entity framework POCO template missing (i am using visual studio 2010 professional )

Hi When i create a .edmx and i hit "Add code generation item" the POCO template is missing, i can only see Entity Object Generator and Sel-Tracking Entities Generator. What am i missing? ...

How enable or disable Entity validation.

I use Entity Framework 4 and MVC 2. I Have an Address Entity, Contact, Company. There are a relation between Contact and Address and Company and Address.. A Contact can Have an Address and a Company can also have an address too. I created a Partial View for Address. <div class="editor"> <%: Html.HiddenFor(model => model.Ad...

Model first vs Data first in Entity Framework .NET 4

Which one should I choose for new project? Could I assume, that data-first model provides better DB performance, and model-first provides better OOP handling? ...

Difference between NHibernate SessionFactory and EF 4.0 ObjectContext

In NHibernate SessionFactory is said to be a heavy object and it is suggested that SessionFactory should be created once in application life span. However once we get handle to SessionFactory, we do call open() on it before doing any DB operation. In EntityFramework we need to create an object of ObjectContext every time before doing an...

Entity Framework 4 POCO CRUD Repository - How to perform Smart INSERT/UPDATE?

Hi Guys, This could be a simple solution, but.... If i have a Entity Framework 4 Repository which exposes the following interface: void InsertOrUpdate(Foo foo); And my EDM is done with custom POCO's (no code generation), how do i perform UPDATE's to POCO's? I can INSERT a new object by doing this: var newFoo = new Foo { ... }; rep...

ADO.Net EF4 CTP Release - New Project

Hi all, I am starting on a new large project and I'd like to use EF4 for the data layer stuff, mainly for the POCO mappings feature. Am I a fool for stating work against a CTP release? Should I wait for the RTM? Given my project will likley take 12 months, could the RTM be out by the end of my project? I'm sure others have been in the...

Code first with EF 4 and documentation

Hi! I know EF4 is still in development but as a newcomer to the subject, I need a document, tutorial etc. with EF 4 code first approach. All the info is in EF 4 Team Blog but scattered around different posts. A full coverage would be really nice. Any one knows of a such place? Thanks. ...

How can I get the Namespace property value from a ConceptualEntityModel at run-time?

I am using C#, Visual Studio 2010 and Entity Framework 4. I have an assembly that contains multiple entity models. Project requirements are such that I am not storing any connection information in the app.config. I have written a method that returns an entity connection string when I supply the name of the model I wish to load. publi...

How do I generate a dynamic connection string in Entity Framework 4?

Is it possible to choose a specific database that will be used with the entity framework? At this time, I use the connection string in the Web.Config as database authentication. I have twelve databases, each of them has the same structure and the same stored procedure. There is one database for each client. When a client wants to login...

Entity Framework 4 - check if navigation property collection is empty, without Include() or Load()

In an MVC view, I'm looking for a way to determine if a parent entity's collection of child entities is empty, so I can decide if I need to call a RenderPartial() or not. For a one-to-one I've been using the following: <% if (Model.Book.GenreReference.EntityKey != null) %> {.....} but I'm unsure how to do it in a one-to-many sc...

Generating fake istances at runtime

I'm looking for an utility class to generate fake entity instances at runtime. I'm implementing a ASP.NET MVC3 website using EF4 with a code-first approach, so I'd like to run the site before creating any database. The fake instances should contain valid data (hopefully reflecting the various DataAnnotation attributes used in each class ...

Entity Framework 4 Code Only Get table name from MetaData for POCO domain object

Hi I am using Entity Framework code only from CTP4. My question is this: given the name of a domain class which is mapped using an EntityConfiguration how can I retrieve the table name for the mapped class at runtime? I'm assuming I need to be using the MetadataWorkspace on the ObjectContext, but finding it difficult to get up-to-date ...

How preserve Entityframework SSDL changes?

How can I preserve SSDL changes? each time I open Entity framework model designer it overrides and remove my casacade delete attribute added to SSDL manually for many to many relations. I am using Entity framework 4.0 and model first approach. ...

Self Tracking Entities vs POCO Entities

We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services. I have been reading a lot about using POCO vs Self Tracking Entities (STE) and from my und...

Database Schema Change and Entity Framework 4 in Release Production Environment

OK, here we go, after reading a couple of related questions, I haven't ended into a real productive solution for my thoughts. Thoughts: As we all developers creating applications, then these apps going into production, the client after couple of days demands additional features. Great! you open your database through Server Explorer, c...