Sign in
Meta-Me
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Tags
.NET 4.0
Architecture
ASP.NET
Associations
Astoria
Authentication
C#
Char
CLR
Code Only
Community
CQRS
Data 2.0
Data Availability
Data Services
Data Services Client
Debugging
Decisions
Design
Designer
DSP
Eager Loading
EDM
EF
EF 3.5
EF 4.0
EF Internals
EF Providers
Entity Framework
Entity SQL
Enums
Escher
Expressions
Extension Methods
FantasySoccer
File Systems
Finds
Fixed Length
Fixup
FK Associations
Fluent APIs
Foreign Keys
Functional
Guidance
Hyperdata
IDataServiceMetadataProvider
IDataServiceQueryProvider
IDataServiceUpdateProvider
Independent Associations
Instincts
Intent
IQueryable
IServiceProvider
JQuery
JSON
Lambda
LazyLoading
Learning
Links
LINQ
LINQ to Entities
Linq to Objects
LINQ to SQL
Mapping
Mental Model
Metadata
Monad
Musings
MVC
NChar
Object Services
ObjectQuery
OData
Optimistic Concurrency
Partial Class
Performance
Philosophical
Pluralization
POCO
Principles
Ramblings
RDF
Reflection Provider
Relationships
REST
Samples
Self-Tracking Entities
Sharepoint
SOA
SOAP
Specifications
SSDL
Statement Expression
StronglyTyped
T4
TechEd2010
Tips
Tricks
Walkthru
WCF
Browse by Tags
MSDN Blogs
>
Meta-Me
>
All Tags
>
ef 4.0
Tagged Content List
Blog Post:
Tip 53 – How to debug EF POCO mapping issues
Alex D James
If you are trying to use POCO classes in EF 4.0, it is relatively easy to run into problems with the mapping from your model to your CLR classes. If you get any nasty problems here, the best way to get to the bottom of things is to try to explicitly load the metadata for your POCO types. For example...
on
11 Feb 2010
Blog Post:
Tip 51 – How to load EF metadata from arbitrary streams
Alex D James
In Tip 45 I showed you how to build a connection string at runtime, which is pretty nifty. The problem with that was that it relies on having metadata files (.csdl .ssdl and .msl) on local disk. But what if they live on a web-server or something and you don’t even have access to the local file...
on
26 Jan 2010
Blog Post:
Tip 47 – How fix-up can make it hard to change relationships
Alex D James
Problem: Take this code: Category oldCategory = ctx.Categories .Include("Products") .First(c => c.Name == "Drink"); Category newCategory = new Category {Name = "Beverage"}; foreach(Product product in oldCategory.Products) { newCategory.Products.Add(product); } Ignore for a second that in...
on
1 Dec 2009
Blog Post:
Tip 46 – How to exclude a property using Code-Only
Alex D James
This time a real simple one prompted by this question on StackOverflow. Problem: If you tell the Entity Framework about this class using Code-Only, by default every property becomes part of Entity, and as a result stored in the database. Usually this is what you want. But not always, imagine this class...
on
29 Nov 2009
Blog Post:
Tip 45 – How to swap EF metadata at runtime.
Alex D James
Background By default the Entity Framework embeds its metadata inside your assembly as a resource. It also puts a connection string in the App or Web Config that references those resources something like this: <add name="BloggingEntities" connectionString="metadata=res://*/Blogging.csdl|res://*/Blogging...
on
29 Nov 2009
Blog Post:
Tip 41 – How to execute T-SQL directly against the database
Alex D James
Sometimes you’ll find you need to issue a query or command that the Entity Framework can’t support. In fact this problem is common to most ORMs, which is why so many of them have a backdoor to the database. The Entity Framework has a backdoor too… .NET 3.5 SP1 In .NET 3.5 SP1 you can get to the underlying...
on
7 Nov 2009
Blog Post:
Tip 33 – How cascade delete really works in EF
Alex D James
Imagine that in your database you have a cascade delete on an FK relationship. Something like this: Here the Delete Rule says that when a Category is deleted all the related Products should be deleted too. If you generate an EF model from this database you get a model that on the surface looks no different...
on
18 Aug 2009
Blog Post:
Tip 32 – How to create a database from SSDL – EF 4 only
Alex D James
We recently released a CTP that extends EF 4 Beta 1 which included Code Only. You can read more about Code Only here , here and here . If you look at the walkthroughs for Code Only you will see code that looks something like this: // Create a builder and configure it var builder = new ContextBuilder<MyContext>...
on
11 Aug 2009
Blog Post:
Tip 30 – How to use a custom database function
Alex D James
Imagine you have a database function like the DistanceBetween function in Nerd Dinner : CREATE FUNCTION [dbo].[DistanceBetween]( @Lat1 as real, @Long1 as real, @Lat2 as real, @Long2 as real) RETURNS real AS BEGIN … END And you want to use it with the Entity Framework. Declaring the Function...
on
6 Aug 2009
Blog Post:
Tip 25 – How to Get Entities by key the easy way
Alex D James
Sometimes rather than writing this: var customer = ctx.Customers.First(c => c.ID == 5); You would rather write something like this: var customer = ctx.Customers.GetCustomerById(5); In .NET 4.0 this would be trivial to do by modifying the T4 templates that do code gen. You would simply...
on
11 Jun 2009
Blog Post:
Tip 24 – How to get the ObjectContext from an Entity
Alex D James
Customers often ask how to get from an Entity back to the ObjectContext . Now generally we don’t recommend trying this. But sometimes you really need a way to get to the ObjectContext . For example if you are in method and all you have is the Entity, and you need the ObjectContext perhaps to do...
on
8 Jun 2009
Blog Post:
Tip 23 – How to fake Enums in EF 4
Alex D James
As of right now Enums are not in EF4. Now we will be listening to your feedback about Beta1, and making some adjustments, so you never know, but at the moment it doesn’t look like they will be supported. Yesterday though I came up with a workaround that, while a bit of work, is pretty interesting...
on
5 Jun 2009
Blog Post:
Ordering of Commands – What do you think?
Alex D James
Some of our customers write code like this: ctx.AddToCustomers(customer); ctx.AddToProducts(product1); ctx.AddToProducts(product2); And expect the Entity Framework to issue 3 insert commands in the same order. Today the EF doesn’t preserve this sort of ordering. Instead the order inserts/updates and...
on
5 Jun 2009
Blog Post:
Learn about EF Pluralization Services courtesy of Dan Rigsby
Alex D James
Not long ago I wrote a ‘sneak peek’ for our new Pluralization features on the ADO.NET team blog. There is a more indepth post coming soon… But it seems the community is starting to do our education for us, and beating us (or should I say me) to the punch! Dan Rigsby , who is a WCF MVP, has a fantastic...
on
22 May 2009
Blog Post:
Tip 21 – How to use the Single() operator – EF 4.0 only
Alex D James
This is 21st post in my ongoing series of Entity Framework Tips , and the first that is specific to EF 4.0. Entity Framework 4.0 Beta 1 As you’ve probably heard VS 2010 Beta 1 is now available to subscribers which means some of you can get your hands on EF 4.0 Beta 1 too. If you have any questions our...
on
21 May 2009
Blog Post:
Tips and Tricks
Alex D James
Hopefully if you're reading this you've noticed that I've started a series of Tips recently. The tips will mostly apply to Entity Framework or Data Services. Seeing as I expect to have a lots of tips, it probably makes sense to have some sort of index. That is what this is post is, as I add...
on
25 Mar 2009
Page 1 of 1 (16 items)