entity-framework-4

EF4 generates invalid script

When I right-click in a .EDMX file and click Generate Database From Model, the resulting script is obviously wrong because of the table names. What it generates is the following script. Note the table names in the DROP TABLE part versus the CREATE TABLE part. Why is this inconsistent? This is obviously not a reusable script. What I cre...

User/Group multiple ownership Model using Entity Framework 4

Hi guys I have to model the following situation. I came up with 2 possible alternatives, but I want to know if there's a better solution. Here's the deal... Simplified Schema User Group ----------- ------------ UserId (PK) GroupId (PK) Name Name ... ... \ / ...

Dump Linq-To-Sql now that Entity Framework 4.0 has been released?

The relative simplicity of Linq-To-Sql as well as all the criticism leveled at version 1 of Entity Framework (especially, the vote of no confidence) convinced me to go with Linq-To-Sql "for the time being". Now that EF 4.0 is out, I wonder if it's time to start migrating over to it. Questions: What are the pros and cons of EF 4.0 rela...

generate only objectLayer of Entity Framework Model by edmgen tool

How to generate only objectLayer by edmgen tool, without generating csdl, ssdl and views ? "%windir%\Microsoft.NET\Framework\v4.0.30319\edmgen.exe" /mode:fullgeneration /c:"Data Source=.\sqlexpress; Initial Catalog=uqs; Integrated Security=SSPI" /project:generateEntityModel /entitycontainer:uqsEntities /namespace:uqsModel...

Solved: TryGetObjectByKey... empty ObjectSets

When I use TryGetObjectByKey on my ObjectContext, it returns an error. An item with a duplicate value already exists. When I look at my objectContext, I see that the ObjectSets are empty. What Am I doing wrong... When I enumerate the ObjectSet by hand, by using ToArray on it, or by using the debugger, it does work. LazyLoadingEnabled =...

How to tell if any entities in context are dirty with .Net Entity Framework 4.0

I want to be able to tell if there is any unsaved data in an entity framework context. I have figured out how to use the ObjectStateManager to check the states of existing entities, but there are two issues I have with this. I would prefer a single function to call to see if any entities are unsaved instead of looping though all entiti...

Help me understand Entity Framework contexts (please!)

Through various questions I have asked here and other forums, I have come to the conclusion that I have no idea what I'm doing when it comes to the generated entity context objects in Entity Framework. As background, I have a ton of experience using LLBLGen Pro, and Entity Framework is about three weeks old to me. Lets say I have a con...

Linq guru - filtering related entities...

My table structure is as follows: Person 1-M PesonAddress Person 1-M PesonPhone Person 1-M PesonEmail Person 1-M Contract Contract M-M Program Contract M-1 Organization At the end of this query I need a populated object graph where each person has their: PesonAddress's PesonPhone's PesonEmail's PesonPhone's Contract's - and this h...

EF 4 - associations with keys that dont match

We're using POCOs and have 2 entities: Item and ItemContact. There are 1 or more contacts per item. Item has as a primary key: ItemID LanguageCode ItemContact has: ItemID ContactID We cant add an association with a referrential constraint as they have differing keys. There isnt a strict primary / foreign key as languageCode isnt in...

Can EF4 support batch updates?

Hi, Does Entity Framework v4 support batch updates/inserts so rather than sending >1 command to a db, it can send >1 command to the DB in one go? Thanks ...

Upgrading Entity Framework 1.0 to 4.0 to include foreign keys

Currently I've been working with Entity Framework 1.0 which is located under a service façade. Below is one of the save methods I've created to either update or insert the device in question. This currently works but, I can't help feel that its a bit of a hack having to set the referenced properties to null then re-attach them just t...

Entity Framework: Generating database from classes

Hi Everyone Is it possible to create the database from the classes with entity framework 4.0? I found many tutorials on how to do it the other way round. But since we have already implemented and tested all classes of the domain we'd like to avoid changing them to much. If I used the wrong keywords in Google I'd appreciate you could pos...

How to get the IBM DB2 provider to work with Entity Framework 4.0

Can someone please tell me how to get the DB2 provider to show up in the "Change Data Source" dialog window? Steps: Right-click on the edmx design surface. Select "Update Model from Database" On the Update Wizard, click "New Connection" Next to the "Data source" textbox, click "Change..." In the Change Data Source window, I am only ...

EF4 cross database relationships

Hello all, I was wondering if EF4 support cross-databse relationships? For instance: db1 Author Id Name db2 Posts Id Content db1.Author.Id What ideally I need to do to get this relation in my ef4 model? Do you guys have any idea? Thanks ...

Help me understand entity framework 4 caching for lazy loading

I am getting some unexpected behaviour with entity framework 4.0 and I am hoping someone can help me understand this. I am using the northwind database for the purposes of this question. I am also using the default code generator (not poco or self tracking). I am expecting that anytime I query the context for the framework to only mak...

Is Entity Framework worth moving to for a new small app?

Hi Is Entity Framework worth moving to for a new small app? About 10 tables and a WinForms app. ie the alternative being DataTables/DataRows or Linq-to-SQL ...

ADO.Net Entity Framework Custom Entity Question

Right... calling all Entity Framework experts... I have a table called Bob in my database, my EF model contains an exact mapping/definition of this. I also have a table called Jim who is also mapped to my entity model. Bob can have multiple Jim's and this relationship is enforced by foreign key constraints as it should be. So the relati...

Full text + spatial search with Entity Framework 4

Let's say I have a SQL 2005 database with a table called Restaurants. The Restaurants table has the following columns: RestaurantId Name Latitude Longitude I want to let users search for restaurants by name and/or address. How do I write the LINQ query to support this? I need to be able to support the possibility that the user doesn'...

dotConnect or "sqlite.phxsoftware.com" for using Entity Framework with SQLite

Which is the better choice out of dotConnect or "sqlite.phxsoftware.com" for using Entity Framework with SQLite (in C#)? ...

Entity Frameworks 4 - Changing the model does not update the T4 self tracking template files

I am using self tracking entities and have moved the entity classes to another assembly by using 'Add as link' to point to the TT file as mentioned here. Now though, when I update the model (for instance change a property name) the template is not automatically run and so the entity class does not get updated. I can of course manually ...