Hello,
I am looking to setup architecture for entity framework that will break apart the entities into multiple models. What I am wondering if it is possible to code-generate one set of entities, so that each model uses the same set of data access classes? I realize the issue with contexts, but I was wondering if each context really n...
I'm still new to EF, and I have figured out some basic queries. I'm stumped on one of the more difficult things I am trying to acheive.
I have 4 entities
User, Tenant, Building, Apartment
Tenant inherits from User
At this point, a user who is not a Tenant can be thought of as a Landlord.
User (Landlord) has one to many Buildings
B...
Hi folks,
We have a simple Table per Type Entity Framework 4.0 model :-
ALl classes are all POCO's.
Post class is abstract.
Discussion and List are classes are concretes, that inherit's from Posts (as shown in the diagram).
When we try to save a Discussion, we do the following code :-
Posts.AddObject(discussion);
And the Sql Ser...
Hi, I've implemented a search-query. It replaces special chars with "normalized" ones. I've apply this rule on different fields. Actually, the query looks very ugly and is full of DRY-violations.
But refacotring this, doesn't seem to be an easy thing (for me). Of course, I just tried to refactor the whole Replace-Stuff into a separate m...
While RIA services seems very good for table operations & queries, I am stuck on one traditional update situation. The UPSERT (Update if exists, else Insert new):
First: I want to add a record server-side if the record does not already exist, otherwise if it already exists, I want to update one of its current field values.
Second: I do...
In NHibernate we override Equals() and GetHashCode() to calculate entity equality.
Is the same necessary in Entity Framework?
The reason I ask is we are using EF4 with POCOs and are in the process of implementing a caching layer. The problem we have is when checking to see if an item is already attached to the object context. Currently...
I have a custom field that I've added to one of my EF entities in a shared.cs file like so:
public partial class Content
{
public int Test = 5;
}
On the client side, the OnCreated handler for that same class looks like this:
partial void OnCreated()
{
this.Test = 42;
}
I've added an event handler to the SavingChanges event ...
OK, I have 3 tables, call them:
Person
PersonID
Name
Store
StoreID
Name
PersonStore
PersonID
StoreID
Now, I have a form which allows you to add stores to a person. However, I am getting the store ID back from the form. I don't really want to do a query to get the store object from Entity Framework. I just want to add to t...
Hi,
I'm starting a project using EF 4 and POCO.
What is the best practice for sending data to the client ? Should I send the POCO or I should have a DTO instead?
Are there any issue I should be aware of when sending the entity (that is disconnected from the context) to the client ?
Is it a recommended practice to send the POCO to ...
Is it possible to return nested complex types from multiple different Stored Procedures using EF? (e.g. ClientSelect, ClientAddressSelect)
I have imported a few stored procedures and added function imports and created a Complex Type for each of the return types. (e.g. Client and ClientAddress).
Now, for example, I want to add the Clien...
I have the following Entity Framework POCO classes:
public class Customer
{
public int Id {get;set;}
public string Name {get;set;}
public virtual ICollection<Order> Orders {get;set;}
}
public class Order
{
public int Id {get;set;}
public int CustomerId {get;set;}
public int OrderTypeId {get;set;}
public v...
Using a DbContext (CTP4) I have the following setup. It works great, but if I exit the first context and then make a new one, and try to query anything, I get the exception..
{"There is already an open DataReader associated with this Command which must be closed first."}
I obviously suspect the problem is that the connection is st...
I've just had a massive blonde moment*, but it's highlighted an annoyance I have with Entity Framework. I have disabled lazy loading so I'm forcing myself to actually think about what data I require in order to keep the application as fast as possible.
So in order to return data within a query, I need to make use of the Include method:...
My ASP.NET MVC 2 application uses Entity Framework 4.0 for the data model. Following the instructions on http://blogs.msdn.com/b/aspnetue/archive/2010/09/17/second_2d00_post.aspx I put the .edmx in its own assembly so my solution has two projects:
MyApp.Core (ASP.NET MVC 2 Web Application Project, references MyApp.DataLayer)
Models/
C...
I'm kind of stuck working out where I'm going wrong with the below entity framework mapping. What I've done is:
a) created a Sqlite database (see below, noting Sqlite doesn't allow FK constraints)
b) created a blank Entity Data Mode & then created the model from the database
c) issue is then trying to add the Model association so it pi...
If I've got a setup where my master page has a member which is an EF generated object, and I want to use this member then within the page itself (but have need for it within the master page as well).
Currently I've got a using loop within the Master Page Page_Init event to establish the member. However if then I try to get any propertie...
I'm attempting to write a CompiledQuery using Linq-to-Entities that will replace a stored procedure that takes two array (in this case, comma-delimited TEXT) parameters. Essentially, the SQL is be something like this:
*Stored Proc definition*
@ArrayParm1 TEXT,
@ArrayParm2 TEXT
-- etc.
SELECT [fieldList]
FROM someTable
WHERE som...
I have a simple 2 object inheritance defined in an EF model, Person <- User.
Person is the base entity/class, it is not abstract, and it contains fields like firstname, lastname, email.
User is the derived entity/class, and contains fields like username, lastlogin, islockedout.
The database uses a table-per-type schema, so there is ...
Here is my database design.
Contact
ContactID
ContactName
EmailAddress
EmailID
ContactID
EmailText
In the create View, I have ContactName Field and a button Add Email Address. When I Click on the Add Email Address, there is a popup who perform an ajax request to get the Address Fields.
My problem is that I need to create the Contac...
I've got standard Create() Edit() and Delete() methods on my controllers, and I am using the EF4 Self-tracking entities.
When the edit is posted back, the model.ChangeTracker.ChangeTracking = false, and model.ChangeTracker.State = ObjectState.Added, even though I made sure those are set when retrieving the record initially.
Are the sel...