I am getting started with Entity Framework 4, and I an creating a demo app as a learning exercise. The app is a simple documentation builder, and it uses a SQL CE store. Each documentation project has its own SQL CE data file, and the user opens one of these files to work on a project.
The EDM is very simple. A documentation project is ...
I'm using EF4 and STE w/ Silverlight.
I'm having trouble deleting child records from my primary entity. For some reason I can remove child entities if their foreign key to my primary entity is part of their Primary Key.
But if it's not, they don't get removed.
I believe these posts explains it:
http://mocella.blogspot.com/2010/01/enti...
Ok, this may sound a little 'unorthodox', but...using VS2010 and the new POCO t4 template for Entity Framework (http://tinyurl.com/y8wnkt2), I can generate nice POCO's. I can then use these POCO's (as DTO's) in a WCF service essentially going from EDM all the way through to the client. Kinda what this guys is doing (http://tinyurl.com/yb...
I am creating a model-first Entity Framework 4 app that uses SQL CE as its data store. All is well until I call ObjectContext.SaveChanges() to save changes to the entities in the model. At that point, SaveChanges() throws a System.Data.UpdateException, with an inner exception message that reads as follows:
Server-generated keys and serv...
I have run into my first dissapointment with Entity Framework 4. It turns out that SQL CE, when used with EF4, does not support autogenerated primary keys. I get a System.Data.UpdateException from OnjectContext.SaveChanges() with this message:
Server-generated keys and server-generated values are not supported by SQL Server Compact.
So...
This is a follow-up to an earlier question I posted on EF4 entity keys with SQL Compact. SQL Compact doesn't allow server-generated identity keys, so I am left with creating my own keys as objects are added to the ObjectContext. My first choice would be an integer key, and the previous answer linked to a blog post that shows an extension...
I try to create some method that can update any changed data from changed Data object (this object is generated by ASP.NET MVC) to old Data object (this object is retrieved from current data in DBMS) like the following code.
public static bool UpdateSomeData(SomeEntities context, SomeModelType changedData)
{
var oldData = GetSomeMod...
Self tracking entities. Awesome.
Except when you do something like
return Db.Users;
none of the self-tracking entities are tracking (until, possibly, they are deserialized).
Fine. So we have to recognize that there is a possibility that an entity returning to us does not have tracking enabled.
Now what???
Things I have tried
F...
Hi,
I have situation in with I stucked and don't know way out. The problem is in my bigger model, but I have made small example which shows the same problem. I have 4 tables. I called them SuperParent, NamedParent, TypedParent and ParentType.
NamedParent and TypedParent derives from superParent. TypedParent has one to many association ...
Hi guys,
I was using the latest EF 4 bits in Visual Studio 2010 RC and have fallen in love with it.
However, I have to develop a small web application using .NET 3.5 SP1 (VS 2008) for work... I was wondering if it was possible to somehow utilize EF 4 in .NET 3.5 SP1/VS 2008.
Regards,
Karan Misra
...
Hi all, I'm so frustrated because of this problem, you have no idea...
I have 2 classes: Post and Comment. I use EF 4 POCO support, I don't have foreign key columns in my .edmx model (Comment class doesn't have PostID property, but has Post property)
class Comment {
public Post post { get; set; }
// ...
}
class Post {
publ...
I am using Entity Framework 4 in a desktop application with SQL Compact. I want to use a private installation of SQL Compact with my application, so that my installer can install SQL Compact without giving the user a second installation to do. It also avoids versioning hassles down the road.
My development machine has SQL Compact 3.5 SP...
I'm doing a talk on the Entity Framework at a local user group next week. I'll be mentioning my own experience with the Entity Framework and I'd like to include other real world experience with the EF.
My questions:
Have you shipped a product that uses the Entity Framework? If so, what industry/market?
If you haven't used the Entity F...
According to this question, there's no built-in way in EF v1 to figure out the length of a field. Is there a built-in way to do so in the Entity Framework that ships with .NET 4, if so - how?
...
Hi,
I am working with Entity Framework 4.0 (VS 2010 Beta 2, NOT RC). I can model the EDM and produce the required database. When I ask VS to generate the code for the model, it generates the expected .designer.cs file. When I look at the factory methods for each entity that the designer has generated, I've noticed that it doesn't inc...
Hi folks,
I have the following pseduo code in some Repository Pattern project that uses EF4.
public void Delete(int someId)
{
// 1. Load the entity for that Id. If there is none, then null.
// 2. If entity != null, then DeleteObject(..);
}
Pretty simple but I'm getting a run-time error:-
ConcurrencyException: Store, Update...
I use Entity Framework 4 and I have parent - child relation with "Cascade Delete" set.
So i would expect when i remove a child from the parent that the child is deleted when i call SaveChanges().
cuRepository.Attach(_controlUnit);
foreach (var recipe in recipes) {
_controlUnit.Recipes.Remove(recipe);
...
Hi,
I'm following this article Using Repository and Unit of Work patterns with Entity Framework 4.0.
I'm tying to implement the Repository and Unit of work pattern, using Asp.Net MVC 2 and Entity Framework 4.
Please let me know if I'm doing it right...
In the Models folder:
Northwind.edmx
Products.cs (POCO class)
ProductRepository....
Can you add an "Or" condition to an entity in the entity framework? For example something like:
Property1 == (1 or 2 or 3)
The message I get when putting the value of "1 || 2 || 3" or "1,2,3" or "1 or 2 or 3" returns this message:
condition is not compatible with the type of the member
...
My current setup:
I have an entity object with some properties, among them an int Id. To communicate with the database, I've created a repository with, among others, the following method:
public int Add(TEntity entity)
{
ObjectSet.AddObject(entity);
return entity.Id;
}
(It's a generic repository, that requires that TEntity is ...