entity-framework

EF 4.0 Code only assocation from abstract to derived

Using EF 4.0 Code only i want to make an assocation between an abstract and normal class. I have class 'Item', 'ContentBase' and 'Test'. 'ContentBase' is abstract and 'Test' derives from it. 'ContentBase' has a property 'Item' that links to an instance of 'Item'. So that 'Test.Item' or any class that derives from 'ContentBase' has an...

ApplyCurrentValues in EF 4

I just was playing with EF 4 in VS 2010 RC and just found that ApplyCurrentValues dont work when the Property is of type bool and the newly value is false !!!??? and it works when the newly value is true . I dont know if this is a bug or I'm missing something but I just work with a very ugly work around : public void UpdateProduct(...

Convert IEnumerable to EntityCollection Entity Framework 4

I have generated the following code with Entity Framework 4 for a navigation property: <XmlIgnoreAttribute()> <SoapIgnoreAttribute()> <DataMemberAttribute()> <EdmRelationshipNavigationPropertyAttribute("Diagnose", "Request_Comments", "Comment")> Public Property Comments() As EntityCollection(Of Comment) Get Return CType(Me,I...

Need to understand Entity Framework reference states

I am implementing the entity framework for the first time. I am working with adding/updating objects that have a parent property. I am aware that the parent entity of an entity is initialized as "null". I do not have a full understanding of how to use the parent entity vs. the parent entity reference fields, or what is required to be ...

Entity framework Querying

Hello Everyone, I am trying to figure out how to query my entities based on the following situation. I have two tables, LKCATEGORY AND LKSUBCATEGORY as you can imagine this two tables are related to each other. However when i come to a page that needs to display only active categories and subcategories how do i do this and pull back a ...

Why is Entity Framework trying to insert NULL?

I have two tables, Quote and Agent. Quote has a column called AgentID that is a foreign key in Agent. When adding the tables to my model in the VS the Quote class has a reference to Agent. When attempting to add a new quote I create a new quote entity and set the Agent like this: entity.Agent = (from x in entities.AgentEntities ...

Using LINQ with IBM i

Has anyone been able to use LINQ with the IBM i? That is without having to write a custom provider? ...

Entity Framework. Saving Changes event. Navigation properties are nulls.

Hi! I'm using Entity Framework. Registering the handler for the SavingChanges event, for the further processing deleted entities. public partial class MyModel { partial void OnContextCreated() { this.SavingChanges += new EventHandler(onSavingChanges); } private void onSavingChanges(object sender, EventArgs e) { Obj...

Does the order of calls to IEnumerable<T>-functions affect the final query when using Entity Framework?

In Entity framework, would the statement MyDataContext.Products.OrderByDescending( (p) => p.Id ).GroupBy<Product,int>( (p) => p.ProductId ).Select( (g) => g.FirstOrDefault()).Where( (p) => p.Name.Equals("Something") ); result in another database query than MyDataContext.Products.Where( (p) => p.Name.Equals("Something") ).OrderByDesce...

Changing the Name of the Connection String that Entity Framework Uses

How do you change the name of the connection string that Entity Framework models are bound to by default? Let's say I create an Entity Framework data model named "Model1.edmx" by pointing it to a databased named "MyDb" and picking some objects to map using the Visual Studio add new item wizard. The EF model is in a class library project...

Entity Framework - restrict users access / inject business rules

Does anyone know of any way to insert in business validation rules within entity frmework? Ideally I want to use dynamicData across some portions of a EF model, and then handle securing access with the EF model itself. For example, if looking at orders, I want to add in a rule that customers can only view their own companys orders. Is ...

Entity Framework 4 + Self-Tracking Entities + ASP.NET Dynamic Data = Error

I'm using the Self-Tracking Entities codegen option in EF4 (VS2010 RC), and I'm trying to use Dynamic Data to build a quick-and-dirty website for editing. The Entities, Data Context, and EDMX files are all in separate assemblies, and this model works well when I call everything in code. But when I try to use it with Dynamic Data, right o...

Application service layer as static classes

In my ASP.NET MVC application, I have a project that contains all the business logic/service layer. This project interacts with my Database (Entity framework) which is located in a separate project. I wanted easy access to the service layer, so I created static classes in it so they can be referenced easily. For example, if I'm in my co...

Entity Framework - How do I join tables on non-primary key columns in secondary tables?

I want to join 2 tables using entity framework. I want the join to the second table to be on a non-primary key column. e.g. I have a table Foo with fields Foo.Id (PK) Foo.DbValue and table Bar Bar.Id (PK) Bar.DbValue Bar.Description And I want to join Foo to Bar in EF on the DbValue field. In hibernate/nhibernate one can do this...

Entity Framework 4 usage with Oracle Db

Are there any known issues of EF usage with Oracle database? Are there any key points I should specially pay attention? Share your toughts and experience please? ...

Entity Framework 4.0 generated entity set vs POCO with INotifyPropertyChanged/IDataErrorInfo

lets assume I do create the entities and I want data binding + error validation in wpf with mvvm pattern. Where is the advance of Poco? POCO is naked and has nothing... no INotifyPropertyChanged or IDataErrorInfo. Due to way much cumbersome work I do not wrap my entities like Customer in CustomerVM/CustomesVM (collection) etc... I return...

.NET EntityFramework: "An error occurred while starting a transaction on the provider connection. See the inner exception for details"

Using Entity Framework in .NET I want to loop through a list of items returned from the database and make updates. var qry = (from c in DBEntities.Customer select c); foreach (Object item in qry) { item.FirstName = .... ... etc, other code here DBEntities.SaveChanges(); } According to : http://social.msdn.microsoft.com/Forums/...

How to debug inserts with LINQ to Entities

Hi All, I have come across this, which is a visualliser for LINQ to Entities which can be used in visual studio, http://www.thinqlinq.com/Post.aspx/Title/LINQ-to-Entity-Visualizer#close=1 The only problem is that it debugs LINQ statements. I am doing an insert statement, is there any way to see what SQL the LINQ to Entities engine is ...

how to call stored procedure that return values from multible tables using entity framework ??

hi every body iam new to Entity framework i have learned about using SP and how to map (insert \ delete \ update) in every table and how to import function to call SP that returns values from one table my question is hot can i to call SP that returns multiple columns from multiple tables in LINQ to SQL generating class that represent...

Validating bool property mapped to int in MVC and Entity Framework

Hello I'am using MVC 2 with Entity Framework (the newest that came with VS2010 RC) and have the following problem: Due to compatibility reasons the example User entity in the database contains field called "Disabled" which is the type of int with values 0 or 1 (to be mapped to bool). In my edmx mappings this field is called 'disabled' a...