entity-framework

How well does IronPython 2.6 integrate with ADO.NET Entities?

If I were to write an application in IronPython 2.6, how easy would it be to use ADO.NET Entities as the DAL? Can anyone point to an example? ...

Best way to share a data model and controls between multiple ASP.NET MVC 2 projects

I am building a suite of applications, each its own MVC solution/project, between these applications I want to share the user auth / user util code (profiles, links to the different applications they can access). I am using the entity framework for data access. My question is what is the best way to share this code between the differen...

Is using public static variables for compiled queries bad in ASP.NET applications?

I'm coding a business layer for an ASP.NET application. I've created database methods in my BLL as static. I've created public static Func variables to be compiled and used in several different methods, like this: namespace BLL public class User { public static Func<Context, variable, result> selectUser; private static void Com...

Problem adding entities in Entity Framework 4

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...

Creating reusable Linq queries

I have a select query which is used over and over with different where filters: var query = from row in context.Table select row; How can I save this into a static class variable so I can reuse it in different methods? Like: var results1 = query.Where(condition1); ... var results2 = query.Where(condition2); ...

What exactly does the EF wizard update when doing "Update model from database" in VS 2010?

Using VS2010 and .NET 4 what exactly does the ADO.NET EF wizard update when you right click in the EF model and select Update from database because I have a feeling that very little. For instance, making a column optional (null values allowed) in SQL Server Management (a value that was previously not nullable) and updating the model in...

Using uniqueidentifier SQL column type with Entity framework

For my primary key and identity in our Clients table I use uniqueidentifier column with a default value set to newsequentialid(). Inserting new rows through the management tool creates the values for the ID fine. Inserting from .NET 4 code via EF results into zero GUIDs (00000-0000....) being inserted. I create the entity with new, set...

LINQ to Entities plus Set Theory: Unable to create a constant value of type 'ITextEntity'. Only primitive types ('such as Int32, String, and Guid')...

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. ...

How is RIA services for relational data efficiency?

I have been researching RIA services with silverlight 4 and considering using it. Switching to silverlight from ASP gives me some concerns about the maturity of silverlight for data driven apps. I was looking at relational data queries. Lets say I have a 'person' table and a 'cars' table. Multiple cars can be associated with a person. N...

How to handle a nullable foreign key field in Entity Framework?

I have a table with a nullable integer field that is a foreign key. When I try to set the entity model's Nullable property to True I get an error that states that fields of type Int32 can not be null. So if Entity Framework doesn't support nullable integers, how can I insert rows into the table with a null value? If no value is specified...

Entity Framework: Different ObjectContext object error with LINQ to Entities assignment

I keep getting the following InvalidOperationException: The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects. when trying to do the following code: newCorr.ReqCode = (from req in context.ReqCodeSet where req.Code.Equals(requirement.Code) ...

RIA Service doesn't pass child entity collections to client side

Hi all, I have a self defined entity in RIA service called EntityA. It contains a EntityCollection of EntityB. I use three attributes on it. [Include] [Composition] [Association("EntityA_EntityBs", "ID", "ID")] public EntityCollection EntityBs { get; set; } Looks like the generated file (...g.cs) get all proper...

Generics and inheritance in C#

I have entity class generated by E-R designer that I have modified a little. This is declaration: public abstract partial class Preference<T> : EntityObject, IPreference<T> Then there is another entity class declared as follows: public partial class BoolPref : Preference<bool> so BoolPref inherits from Preferences<bool>. Now I have...

How can my button close the window and refresh the parent after updating formview?

I have a "Save" button on a FormView with the CommandName="Update" set. This button updates an EntityDataSource that is bound to the FormView. After the EDS is updated, I want to close this (child, popup) window and refresh my parent window (so it will reflect the changes just made to the data). For reference, I have a similar "Cancel"...

EF4 for an nHibernate developer?

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...

Error in addobject in Entity framework

hi i have problrm with this ihave class with name patient that each patient have patintcase and insuranseinfo when i try to add patient i recive this error (The EntityKey property can only be set when the current value of the property is nul) and here is my code: public Patient(Doctor doctorname, string n, string f, string codeme...

LINQ to Entities with AddMonth method

This is my code: return Newsletterctx.Subscribers.Count(o => o.Validated == false && o.ValidationEmailSent == true && o.SubscriptionDateTime.AddMonths(1) < DateTime.Now); I get this error: LINQ to Entities does not recognize the method 'System.DateTime AddMonths(Int32)' method, and this method cannot be trans...

ObjectContext instance has been disposed problem while binding

This is my code: public class JobsRepository:BaseNewsletterRepository { public IEnumerable<Job> GetJobs() { var jobs = Newsletterctx.Jobs.Include("Info").OrderBy(o => o.JobID); return jobs.AsEnumerable(); } } public class BusinessNewsletter { public static IEnumerable<Job> GetJobs() ...

Entity Framework / EF4: Multiple inserts of related entities in a transactionscope

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();...

how add entityobject with exsist object that have relational in Entity framework

Hi my scenario i want to create application for dental clinic . I have vs2010 ultimate and first time started with empty model and then I crate it with Generate database from model…… now I have afew class which some of this makes paritial by me because to extend flexible I have class with name patient and doctor that derived from Per...