entity-framework

Serializing Entities with RIA Services

I've got a Silverlight application that requires quite a bit of data to operate and it requires it all up-front. It's using RIA Services (and the Entity Framework) to get all that information. It takes 10-15 seconds to get all the data, but the data only changes about once a month. What I'd like to do is toss that data into Isolated Sto...

Generating entity class files from table schema

I am using LINQ to SQL with C#. Is there a method through which we can generate entity class files from the table schema? By dragging tables onto the graphical designer classes are generated but they are not the real class files(i mean actual files with the extension cs). I am aware of that we can code the class files first and then cr...

Mapping collection of strings with Entity Framework or Linq to SQL

I would like to know if it is possible to map a 1-many database relationship as an array of primitives on the parent object class. For example, say I have a database as follows: TABLE: PERSON ID - int TABLE: PERSON_EMAIL_ADDRESSES PERSON_ID - int EMAIL_ADDRESS - string For my Person class, I'd like to have the following:...

ORM tool OR build the object to relational mapping layer manually

I am trying to determine what if any advantage or disadvantage there is to using an object to relational mapping layer like hibernate or the Microsoft Entity framework when building the data layer. Is using sql and mapping objects by hand better in the long run or is it better to leverage one of these mapping technologies? It seems ...

creating objectquery

Hi I have an ef model and i want to "query" it using objectquery. So far i create my objectquery like this: myQuery = new ObjectQuery<T>(mergeOption, context) Is it possible to create an objectquery without the specifying the context right from the start (set it later on)? In my application i have multiple threads that needs to get t...

What advantages does pairing .Net development with SQLServer give in terms of ORM?

In Java, Hibernate is king in terms of automating code/DB synchronization. And I'm aware NHibernate is a .NET equivalent, and that LINQ has some cool SQL functions (despite not being developed further IIRC). But, is there any advantage from pairing .Net development with a SQLServer database? Magic automatic persistence of objects perhap...

Why use an ORM?

Possible Duplicate: Why should you use an ORM? This quote is from the book "Asp.net mvc framework unleashed" by Walther and so far is a very good book. The Entity Framework shields you from needing to interact directly with the database. By taking advantage of the Entity Framework, you never need to write SQL queries aga...

EF InvalidOperationException More than one item in the metadata

Hi, I have a problem with saving changes in Enitity Framework. I create a new repository, which creates a new ObjectContext. I then use Films.First(u => u.film == filmId); to get the object, update some of the properties and then call repository db.SaveChanges(System.Data.Objects.SaveOptions.None); I then get the error: InvalidOperatio...

Entity Framework many-to-many question

Please help an EF n00b design his database. I have several companies that produce several products, so there's a many-to-many relationship between companies and products. I have an intermediate table, Company_Product, that relates them. Each company/product combination has a unique SKU. For example Acme widgets have SKU 123, but Omega w...

Update Wizard (Entity Framework) - VSS 2008 not updating view. Should I manually update it?

I am using VSS 2008 and built a Entity Framework model from SQL server 2008 database. Everything worked fine. Now I have updated a view to include a new column and tried refreshing the entire model from DB but the updated column in the view is not visible. I opened the EDMX as XML to see the problem and it has a warning ... Errors Fou...

How to add and reuse objects in a many to many relationship in Entity Framework?

I'm working on an asp.net-mvc project. I have an Items table and a Tags table. There's also an ItemTags table made up of two columns, setup as a composite key, storing Id's from the first two tables. Mapped to EntityFramework this latter table enables navigation between the tables. When i add a new Tag for a specific Item i use: db....

LINQ - Join Two Entities into One IQueryable Complex Type - EF4 and ASP.Net MVC

Hi I have code like: var entityX = this._xService.GetAll(); var entityY = this._yService.GetAll(); Both are returned as IEnumerable types. I need to inner join the two into a something like a JoinedList class that has to be IQueryable. I'm looking for ways to do this please using LINQ. Many Thanks ...

Comboboxes in GridView are synchronized instead of bound to the value from the database

I have tried to set up combo boxes in the gridview but all the combo boxes have the same value in them instead of the value from the database. I am using entity framework and WPF. There is a parent child relationship between two tables but the source for the combo box is a separate table with names and IDs for tags. I have been looking a...

linq group by and list

i have function public List<string > UserList() { var q = from i in _dataContext.PageStat group i by new { i.UserName } into ii select new { ii.Key.UserName }; } how can i return List ? ...

Is it possible to use EF 4.0 without having a dependence on .NET 4.0

Lets say I build an Service Layer wich deals with POCOs coming out of an repository. The Repository is aware of the EF 4.0 and deals with POCO generation and so on. But that does also mean that my Repository will have a .NET 4.0 dependency and so my Service Layer which consumes the Repository will also have a .NET 4.0 dependency...even i...

Comparing DateTime in Entity Framework with an Sql Server Compact database

Why this code throws a System.NotSupportedException telling that The specified method 'int? DateDiff(string, DateTime?, DateTime?)' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression, though DateDiff has EdmFunction attribute? context.Users.Where(f => System.Data.Object...

DataBinding with entityframework bug

Hi, I have an application which consists of simple schema of DB: Networks 1-->* Shops i use entityframework (Default EntityObject Code Generator) with winforms, i use DataBinding to a grid to CUD these entities, i have : DbObjectModelContainer _context = new DbObjectModelContainer(); _context.ContextOptions.LazyLoadingEnable...

Concurrency check fails with hierarchical data EF 4.0

Hi. I got a problem with Entity Framework 4.0 I have a hierarchical table Category: Id, Name, ParentCategory_Id, timestamp The "timestamp" field is marked as "Concurrency Mode" = "Fixed" And I'm using Self-Tracking Entity "Category" to manage Category entity in my MVC application. The situation: I create STE "NewCategory", set ...

ef and linq extension method

Hi I have this sql that i want to have written in linq extension method returning an entity from my edm: SELECT p.[Id],p.[Firstname],p.[Lastname],prt.[AddressId],prt.[Street],prt.[City] FROM [Person] p CROSS APPLY ( SELECT TOP(1) pa.[AddressId],a.[ValidFrom],a.[Street],a.[City] FROM [Person_Addresses] pa LEFT OUTER JOIN...

Self Tracking Entities versus timestamp column in database

In an optimistic concurrency scenario fo a web-app, I am considering to give each table the timestamp column (sqlserver), comparable to a guid. Linq to entities will then generate sql update queries like WHERE id = @p0 AND timestamp = @p1 when one decorates the timestamp column with a certain attribute in Entity Framework. When the numb...