I'm trying to create a method on an EF 4 POCO repository called AddOrUpdate.
The idea is that the business layer can pass in a POCO object and the persistence framework will add the object if it is new (not yet in the database), else will update the database (once SaveChanges() is called) with the new value. This is similar to some oth...
I have run into an "issue" I am not quite sure I understand with Entity Framework. I am using Entity Framework 4 and have tried to utilize a TDD approach. As a result, I recently implemented a search feature using a Repository pattern. For my test project, I am implementing my repository interface and have a set of "fake" object data I a...
Hi,
We're using EF4 in a fairly large system and occasionally run into problems due to EF4 being unable to convert certain expressions into SQL. At present, we either need to do some fancy footwork (DB/Code) or just accept the performance hit and allow the query to be executed in-memory.
Needless to say neither of these is ideal and th...
I have an Entity Framework 4 model-first design. I create a first draft of my model in the designer and all was well. I compiled, generated database, etc.
Later on I tried to add a string scalar (Nullable = true) to one of my existing entities and I keep getting this type of error when I compile:
Error 3004: Problem in mapping
fra...
Lets say I have two tables like this:
person: id, first_name, last_name, phone_id
phone: id, phone_number
person.phone_id is always equal to a phone.id. Instead of my entity showing person.phone_id, I'd like it to show person.phone_number. How can I accomplish this?
...
When I originally created a Dynamic Data project I told it to expose the foreign keys, but now I can't make mappings between two entities b/c of the foreign keys. When I click on mapping details while focused on my association I receive the message:
Mappings are not allow for an association over exposed foreign keys.
So I'd like to...
I created a new Entity Framework model from a database. This database has a number of tables, the main table is phones_extensions. The phones_extensions table has columns which are FK's to the other tables - e.g. the restriction_class_id is an FK linking to the phones_restictions_class table where the PK is ID.
The EF4 model automatical...
Hi guys.
I have a table that has a column called "rowguid" with default value of newguid(). After I delete the generated property in the Entity Framework 4.0 designer, whenever I try to build or validate the model I receive the following error message.
Error 3023: Problem in mapping
fragments starting at line 1460:Column
People....
Hi,
I have co-workers working on an Entity Framework model that changes structure (entities), over time as software development progresses. I've written some utilities that interact with the tables within the model, but I'd like to have the code dynamically discover the tables. Is there a way I can do this ? Perhaps with ADO.NET to g...
Looking at Code First in ADO.Net EF 4 CTP 3 and wondered how the SqlConnection in their walkthrough is disposed. Is that the responsibility of ContextBuilder? Is it missing from the example?
var connection = new SqlConnection(DB_CONN);
var builder = new ContextBuilder<BloggingModel>();
var connection = new SqlConnection(DB_CONN)...
Hi,
I’m using Visual Studio 2010 with .NET 4 and Entity Framework 4. I’m working with POCO Classes and not the EF4 Generator. I need to overwrite the Equals() and GetHashCode() Method but that doesn’t really work. Thought it’s something everybody does but I don’t find anything about the problem Online.
When I write my own Classes and E...
Hi guys,
I'm using AdventureWorks 2008 R2 database and added the BusinessEntity and Person tables to my EDMX. Then I changed the model in which the Person table inherits from the BusinessEntity table. As you may know these two tables have ModifiedDate and rowguid columns so the Person class should not have these properties because it inh...
Hi,
I would like to implement an application wide retry system for all entity SaveChanges method calls.
Technologies:
Entity framework 4.0
.Net 4.0
namespace Sample.Data.Store.Entities {
public partial class StoreDB
{
public override int SaveChanges(System.Data.Objects.SaveOptions options)
{
...
I'm trying to run through this msdn article:
http://msdn.microsoft.com/en-us/library/dd723645.aspx
One of the steps is:
In the class file for the page, change the base class from UserControl to EntityTemplateUserControl.
Nowhere is it made clear what page is being referenced. Can someone help me? I don't see any relevant class in t...
To clearify: I use the POCO generator so that the entities are not tightly bound to the EF implementation.
In my entities, I tend to add comments for the properties but as I update the model and save it, all the comments are removed.
How can I prevent this behavior?
...
Hey,
I'm using .NET 4 EF and am trying to save the child entities (InvoiceLogs) of an entity (Invoice). On form submit I have a detached invoice object that has an EntityCollection of modified InvoiceLog entities passed to my controller action. I then attach the invoice to the data context and call SaveChanges. The problem is that this ...
I have a rather deep hierarchy of objects that I'm trying to persist with Entity Framework 4, POCO, PI (Persistence Ignorance) and Code First. Suddenly things started working pretty well when it dawned on me to not use the new() operator. As originally written, the objects frequently use new() to create child objects.
Instead I'm usin...
Unless a class specifically overrides the behavior defined for Object, ReferenceEquals and == do the same thing... compare references.
In property setters, I have commonly used the pattern
private MyType myProperty;
public MyType MyProperty
{
set
{
if (myProperty != value)
{
myProperty = value;
...
Does anyone know of or having any good examples of how to use Entity Framework version 2 in the Data Access layer and put an interface on it so the business layer uses the interface rather than knowing about EF? I have found some examples but they are all from 2009 and I'm not sure how they relate to Entity Framework version 2.
...
Hi,
Is it possible to run a query on an EF4.0 data context and get all objects of a certain type?
Say the context has books, genres & authors but I only have a generic parameter, t. Is it possible to get all of type just by using this t?
I don't think it is :(
...