entity-framework

Creating an entity for a link table in EF4

I have 3 tables Table 1 Id Name Table 2 Id Name Link Table Table1Id Table2Id The link table sets up a many to many relationship between Table 1 and Table 2. I'm using the entity framework which does not automatically create an entity for the Link Table and I need to be able to manage that table directly. Therefore, I need ...

ORM vs SQL XML, very simple middle-tier

I know it is rather heated question. But anyway I'd like to hear opinions of those in Stackoverflow. Given that XML support is quite good in SQL Server 2005/2008, and there's no concern about database independency, why one need Linq-to-SQL, Entity Framework, NHibernate and the likes, which are quite complex and awkward in advanced use-ca...

How to force refresh all entities in Entity Framework 4.0

Hello, I'm wondering if it is possible to refresh all entities from data model as opposite to refresh them one by one. Something like entities.RefreshAll(); Regards, Daniel Skowroński ...

Make entity framework case-insensitive

Is it possible to set entity framework string comparison case insensitive by default? If I use string.StartsWith("stringToCompare", StringComparison.CurrentCultureIgnoreCase), it works. But when I need to use string.Contains("strigToCompare") it doesn't have an overload. ...

Multiple join query in eSql

Hi guys, This is my first question in stackoverflow but really not the first time to get solution here. I am struggling with multiple join in entity framework 4. I have three tables (Accounts, Users and AccountUsers) that am finding difficult to query. What I want is to get all the users for the provided accountId including the account ...

entity framework navigation property further filter without loading into memory

Hi, I've two entities with 1 to N relation in between. Let's say Books and Pages. Book has a navigation property as Pages. Book has BookId as an identifier and Page has an auto generated id and a scalar property named PageNo. LazyLoading is set to true. I've generated this using VS2010 & .net 4.0 and created a database from that. In t...

EF OrderBy method doesn't work with joins

Following works (ordered by name): from t in context.Table1.OrderBy( "it.Name" ) select t This doesn't work (no ordering): from t in context.Table1.OrderBy( "it.Name" ) join t2 in context.Table2 on t.SomeId equals t2.SomeId select t Nor does this (trying to reference the parent table to order): from t in context.Table1 ...

how to get object that triggered constraint violation in entity framework

Hi everyone. Here is the situation: Lets's imagine we have table A in the database and we've created Entity model for that table. Let's also imagine that there are several Uniqeu and Foreign constraints in that table. Now let's do the following: load more than 1 record from that table into the context. Change some objects to make som...

How to bind entity model to WinForms DataGridView with specific column names?

Currently I am doing: var items = from t in entity.Items select new { Name = t.ItemName, Description = t.ItemDescription }; myDataGridView.DataSource = items.ToList(); The problem is that when bound to the DataGridView, I get two columns of "Name" and "Description". I want to rename these to "Item Name" a...

What am I doing wrong?

First I come from a nettiers background. And I really think that is getting in the way of trying to figure out how to use EF4. Second. I am using the POCO templates available from MS. I have lazy loading enabled as well as proxy generation. in my application I am eagerloading an selected doctors information from my users selection: do...

Repository pattern design considerations

Hi all, I am currently in the process of designing/implementing a repository pattern in a .NET application. After many days of research I feel I am getting close but there really is so many ideas and opinions out there I was hoping to get some peoples thoughts on any design considerations they may have had if you've implemented one your...

WPF and ADO.NET EF - error

Hi, I keep getting this error: Microsoft.Practices.Composite.Modularity.ModuleInitializeException was unhandled Message=An exception occurred while initializing module 'DiagrammerModule'. - The exception message was: An exception has occurred while trying to add a view to region 'MainRegion'. - The most likely causing except...

Entity Framework: Column must be mapped although it does have a default value?

Hi, I am trying to create an Entity Framework 4 model based on a legacy SQL server 2008 database. Since the model is going to be published in a web service, I need to omit an integer column called NewsletterSubscribed from one of the model's entities. After removing the column in the EF designer I got the following compilation error: ...

Domain model doubts...

Hi all, From one side, I want to write a killer app(in ASP.NET MVC) ;) But from the other side, I have many doubts if I should keep to so called "best practices" at all cost. So I have a design question and I really hope you can help me out. Imagine a standard blog. I want to show 10 most recent posts. My database has standard Posts, C...

Entity Framework SaveChanges - how to ignore ID / Identity fields on INSERT

VB .NET 4 WinForms application. I have a (DevExpress) grid bound to an IEnumerable(Of MyClass). Whenever a new row is added, the ID defaults to zero (0). On trying to SaveChanges, EntityFramework doesn't realise that being an identity field means it should ignore any contents on insert and just insert the other values. I can't specify n...

Using WCF 4 and EF 4

When using wcf and entity framework 4 is it necessary to use POCO? If not how to combine DataContracts with generated classes(i figure one solution is to recreate the domain classes as business classes)?Or what is the best way co combine wcf 4 and ef 4? ...

Migration from linq2sql to EF4.0

In linq2sql I had this code to implement base class for repository public abstract class Repository<T> : IRepository<T> where T : class { protected DataContext context; protected Table<T> table; public Repository (DataContext context) { this.context = context; table = context....

I'm a Linq-to-SQL rookie, but I'm looking into Entity Framework. Is it much harder to use?

For example, one of the joys I've learned from L2S is that when creating the .dbml file, it automagically lets me create object of the Table with fields of the table columns. I do absolutely nothing and I can query things using a very natural approach using Linq and lambda expressions. I've also been told that L2S doesn't work with many...

entity framework: How to relate 2 tables..

I have following tables: Profiles: ProfileID (Primary Key) ProfileName, etc. Contacts: ContactID (Primary Key) ProfileFromID (Foreign Key) ProfileToID (Foreign Key) Message varchar(50) , etc. Profiles could have many contact messages. So a given message will have who sent the message and to whom the message was sent. I am having di...

WPF and ADO.NET EF - error part II

Hi, I have added the connection string to the App.config of a main executable in my wpr, prism application and I get the following error: System.TypeInitializationException was unhandled Message=The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception. Source=Microsoft.Practices.EnterpriseLi...