In the constructor of each of my POCO's I have this:
this.StartTracking();
To ensure that tracking is turned on for every instance of one of my POCO's. I have an Entity A which contains a TrackableCollection of Entity B. When I load my instance of Entity A like such:
using(MyContext ctx = new MyContext())
{
entityA = ctx.EntityA....
I am trying to figure out something with EF4 Code Only. If i use TPH and i wanted to change a saved Person to Instructor or vice versa, how would i accomplish this. My POCO classes:
public class Person
{
public int PersonId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
publi...
I'm having a strange problem with new Entity Framework for .NET 4
I have a SQL Server 2005 (EXPRESS) database and my service writes data to two tables using entity framework. Let's say tables are TableA and TableB. TableB has foreign key to TableA. In my program there are several threads that writes data in parallel. Each thread has its...
Hi
I have an entity that has a primary key that is set to identity and the type is bigint (long in C#).
When I add a new object to ObjectContext and try to save changes to the database, I get the following error:
A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'."
I don't really unde...
Hi,
Given an Entity Data Model (EDMX) with "Code Generation Strategy" set to "None", how does EF determine which CLR types to map the conceptual model to?
I think I read somewhere that it just probes the assembly for types that match the conceptual model, but that was in reference to a CTP edition of EF. Is this still the case?
Can I...
Hello,
I would like to achieve the following:
A service is called with a DTO as parameter. I would like to know the simplest way to save the changes if that DTO consists in an existing entity with a modification (Parent with an update) and a related entity which is new (child with an insert).
Thanks in advance
...
I did look at common implementations of EF Repository pattern on the web.
Then i came with such question. For example if i have method like that:
public IEnumerable<Entity> FindEntity(Expression<Func<Entity, bool> where) {...}
Than If i have such case where i need to have IList instead of IEnumarable
i may create IList based on m...
I have a LINQ to Entities query (using EF 4) that has some pretty complicated set-based filtering going on. The code compiles just fine, but when I try to run it, I get the following error:
Unable to create a constant value of type 'ITextEntity'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
...
hi all
I've seen similar questions asked, but the answers haven't helped me yet. I am modelling TPH in my system (going POCO by the way), for data that is displayed in a Treeview (some sort of collection of the superclass is loaded and displayed). Now I need to do various things (such as UI styling, bizrules etc) based on the type of eac...
This is entity framework 4.
CurrentProperty.FMVHistories.Add(FMVPresenter.GetFMVHistoryObject());
DataLayer.AccrualTrackingEntities repository = new AccrualTrackingEntities();
repository.Properties.AddObject(CurrentProperty);
repository.SaveChanges();
Right before I call SaveChanges, CurrentProperty has 1 object in its FMVHistories ...
I'm needing to foray into EF4 for the first time since experiencing the disappointment that was v1. Since then I've been a happy nHibernate user but I'm needing to pick EF back up now for a new project due to client preference.
Has anyone created a quick guide of analogies between ORM concepts for the two? If I had a translation of nH...
Hi,
I have a similar problem.
I want to make two inserts in the same transactionscope. The objects are related and have a FK relationship between them, but for several reasons I do not want to connect them via the navigation property, but only by ID.
This is a simplification of what I what I want to accomplish:
Order o = new Order();...
I have an "Edit Page" in my application. It uses a FormView bound to an EntityDataSource.
I have a handler setup for the FormView OnItemUpdating event. If an exception occurs, I set the "KeepInEditMode=true". This should retain the user entered values on all of the text boxes instead of rebinding the FormView to the data again. (Right?)...
I am attempting to be a good TDD citizen as I design an application. I'm using Moq, and I've run into a little repository issue.
My repository has a Find method:
public IEnumerable<T> Find(Expression<Func<T, bool>> where)
{
return _objectSet.Where(where);
}
Then I attempt to set up a mock of the repositor...
I am building an asp.net site in .net framework 4.0, and I am stuck at the method that supposed to call a .cs class and get the query result back here is my method call and method
1: method call form aspx.cs page:
helper cls = new helper();
var query = cls.GetQuery(GroupID,emailCap);
2: Method in helper class:
public IQueryable<V...
I'm a newbie to Entity Framework, so I'd like to try something simple to get started on Visual Studio 2010.
Suppose I start out with the following SQL statement (the View sys.databases exists in the master database on SQL Azure):
SELECT name, create_date
FROM sys.databases
WHERE database_id > 3
So instead of using traditional ADO...
I am developing a small application using EF 4.0 and POCO.
While testing my application, I grew concerned about the performance of the Data Access Layer. So I fired SQL Profiler to see that when trying to retrieve a record:
ctx.Orders.Include("OrderItems").FirstOrDefault<Order>(c => c.OrderID == id);
the EF issues a SQL statement th...
Hi,
I have
List<Car> cars =
from c in myContext.Cars
.Include("Wheels")
.Include("Wheels.Nuts")
orderby c.CarID
These are all EF default generated objects.
I want to turn this into JSON string containting all cars, each with its wheels, and each wheel with with its nuts, just like I would get ...
Hi,
I am trying to create a TPH inheritance hierarchy using foreign keys / navigation properties as discriminators and I am having some trouble getting it right.
I have the following entities:
Person:
Id (int)
Name (nvarchar)
PlaneId (int)
CarId (int)
Car:
Id (int)
Name (nvarchar)
Plane:
Id (int)
Name (nvarchar)
wi...
The problem: When I try to do an update using an EntityDataSource and a FormView that has an asp:DropDownList linking to another table, the page loads fine with the proper setting, but on update I get this error message:
A property named 'Vendor.VendorId' was not found on the entity during an insert, update, or delete operation. Check t...