entity-framework

How to Add, Edit and Display one to many relationship entities in ASP.Net MVC 2?

I am looking for best practices conforming to the MVC design pattern. My Entities have the following relationship. tblPortal PortalId PrortalName tblPortalAlias AliasId PortalId HttpAlias Each Portal can have many PortalAlias. I want to Add a New Portal and then Add the associated PortalAlias. I am confused on how I should structure ...

How to retrieve base class only (entity framework)?

Hi All, I've been scratching my head here for a while now... I have a Consumer class and a BillableConsumer class that inherits Consumer. They are both a part of the Consumers set. The problem is that this following query: Consumer consumer = (from c in _ctx.Consumers where c.ID = id select c).First(); returns a BillableConsumer ins...

How to convert an EntityCollection<T> to List<POCOObj>

I have Entity Framework entities Events which have an EntityCollection of RSVP. I want to convert the EntityCollection of RSVP to a generic List<> of a POCO class RSVP. So I want EntityCollection -> List. What would be the best way to go about achieving this? So far I have this (it's missing the RSVP part) var events = from e in _en...

How to speed up saving data to database over the internet?

I am using C#, Entity Framework and SQL Server 2008 Express. I am connected to the database over the internet. What is the best method to speed up saving/updating data to database? It takes 87 seconds to save 180 records to the database. It takes only 3.5 seconds to save the same number of records to local (on the same machine) SQL Serve...

EF in a UserControl can't see the app.config?

I just created a user control. This control also makes use of my static Entity Framework class to load two comboboxes. All is well and runs without a problem. Design and runtime are working. Then when I stop the application all the forms that contain my UserControl don't work any more in design time. I just see two errors: Error1: The ...

TypeConverter prevents ApplyPropertyChanges in EntityFramework

I ran into an interesting problem (hopefully, interesting not just for me :) I am running Entity Framework 1 (.NET 3.5) and ASP.NET MVC 2. I have a Customer class that has many-to-one relationship with Country class (in other words, Country is a lookup table for customers - I described more in this post: http://stackoverflow.com/questio...

Entity update from ASP.NET MVC page with post to Edit action

My form includes a subset of Client entity properties and I also include a hidden field that holds an ID of the client. The client entity itself is provided via the GET Edit action. Now I want to do entity update but so far I've only been trying without first loading the entity from the DB. Because the client object that comes in POST E...

ADO.NET Entity Framework or ADO.NET

I'm starting a new project based on ASP.NET and Windows server. The application is planned to be pretty big and serve large amount of clients pulling and updating high freq. changing data. I have previously created projects with Linq-To-Sql or with Ado.Net. My plan for this project is to use VS2010 and the new EF4 framework. It woul...

Entity Framework and the XmlIgnoreAttribute

Say you have a one to one relationship in your entity model. The code generator will decorate it with the following attributes: [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] public RelatedObject Relationship { get {...} set {...} } I want to serialize my parent object...

insert,update, delete derived entity in entity framework 4.0

Hi! How do i insert an entity that is derived from another entity. here is my code but it's not working:(applicationreplacement derived from application public void AddReplacementApp(Application entity,ApplicationReplacement rentity) { _ctx.CreateObjectSet<Application>().AddObject(rentity); _ctx.SaveChanges(); ...

Interface -> Entity Mapping

Hi guys, Suppose I have a few definitions like so: public interface ICategory { int ID { get; set; } string Name { get; set; } ICategory Parent { get; set; } } public class Category : ICategory { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual ICategory Parent { get; ...

ADDTOENTITY not available on my context

why is it that i dont have AddToEntity (ex: AddToCustomer) not available on my context..all i have is AddObject..? Thankx. I am using EF 4.0 ...

How do I deal with connection strings in a Click-Once application?

I'm thinking of building a Click-Once application, and am trying to wrap my head around how to handle the whole connection string issue. The problem is the following: I want to use EF to get data directly from each client, thus requiring each client to have a connection string configured (this is not the issue). How do I deal with clien...

How to implement table-per-concrete-type strategy using entity framework

I'm mapping a set of tables that share a common set of fields: So as you can see I'm using a table-per-concrete-type strategy to map the inheritance. But... I have not could to relate them to an abstract type containing these common properties. It's possible to do it using EF? BONUS: The only non documented Entity Data Model Map...

UpdateModelFromDatabaseException when trying to add a table to Entity Framework model

I'm running into a weird issue with Entity Framework in .NET 3.5 SP1 within Visual Studio 2008. I created a database with a few tables in SQL Server and then created the associated .edmx Entity Framework model and had no issues. I then created a new table in the database that has a foreign key to an existing table and needed to be adde...

JavaScriptSerializer().Serialize(Entity Framework object)

May be, it is not so problematic for you. but i'm trying first time with json serialization. and also read other articles in stackowerflow. I have created Entity Framework data model. then by method get all data from object: private uqsEntities _db = new uqsEntities(); //get all data from table sysMainTableColumns where tableName=param...

Where to execute extra logic for linq to entities query?

Let say that I want to populate a list of CustomerViewModel which are built based on Customer Entity Framework model with some fields (like Balance) calculated separately. Below I have code which works for lists - it is implemented in my service layer, but also I want to execute this code when I just get one item from the database and ex...

Entity Framework - One to One relationship, how to save record

I have a one-to-one relationship on two tables with are represented by 2 classes in my EDM. I am trying to save a new record and am confused how to save to the second entity. I have tried the following. Dim myObject as new MyObject myObject.prop1 = 5 myObject.prop2 = "Test" myObject.myOtherObject.prop1 = 3 myObject.myOtherObject.pro...

Replace Entity Framework object

In MVC app, I am having this big object that is used in classic view/edit/create pattern. When user edits the object I save it as: public bool SetMyObject(MyObject newObject) { MyObject current = GetObjectById(newObject.Id); current.Prop1 = newObject.Prop1 ... current.PropN = newObject.PropN db.SaveChanges();...

CA: Suppress results from generated code not working in VS2010 beta 2

I'm trying to run codeanalysis on an assembly that contains an entity model (edmx file). In project properties I have checked the "Suppress results from generated code" option, but I am still getting a lot of CA errors pertaining to the auto-generated EF code. Has anyone experienced this? And is there a work-around? ...