entity-framework-4

Selecting particlar fields with EF4.0

First of all there is error message: The entity or complex type 'AdventuresWorks.ProductSubcategory' cannot be constructed in a LINQ to Entities query. Here is mu POCO class: public class ProductSubcategory { public Int32 ProductSubcategoryID { get; set; } public Int32 ProductCategoryId { get; set; } p...

.NET 4.0 CTP and EF CTP - is it good enough for production code?

I'm very interested in using 4.0 framework and also the Entity Framework 4.0. Currently .net 4.0 is in CTP and I'm EF 4.0 is in CTP Preview. I will not be coding for a few more months, but i'm not so sure that either .net 4.0 or EF 4.0 will be RTM by then. My questions: 1) Regarding Microsoft Products, is CTP usually stable enough ...

Exclude a field/property from the database with Entity Framework 4 & Code Only

I will like to know that is there a way to exclude some fields from the database? For eg: public class Employee { public int Id { get; set; } public string Name { get; set; } public string FatherName { get; set; } public bool IsMale { get; set; } public bool IsMarried { get; set; } public string AddressAs { get...

Entity Framework 4 Multiple Object Delete(RemoveAll)

I read that the new Entity Framework will include a method to delete multiple items (Linq to SQL has DeleteAllOnSubmit()) but I can't find the function/method to do that. Is this in Beta 2 or do I have to make my own? UPDATE: This is what I'm using now: public void DeleteObjects(IEnumerable<object> objects) { foreach ...

Mocking Entity Context in EF4

I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF. var context = MockRepository.GenerateMock<SomeDBEntities>(); IObjectSet<TxMode> objectSet = new List<TxMode> { mode }.AsObjectSet(); context.Expect(c => c.TxModes).Return(objectSet); The problem is that c.TxModes is a property of...

RIA services, EF and stored procs

I have this problem for 2 months now How can I use stored procedures whith RIA. I was using LinqToSql and everithing works fine. I've made an class in designer and mapped it to a SP. Now in EF I saw this ComplexTypes I've imported son SP with result in ComplexTypes. But in DomainDataSource are not appear. OK. But how can I use the...

Is there any way to install EF4 on VS2008 SP1?

After googling, I have only found only this sad forum question. Is it true I can't install EF4 on VS 2008 SP1? And if I can, how to do it - just install .NET 4 beta 2? ...

Table per hierarchy inheritance with POCO entities in Entity Framework 4

Our organization is looking to standardize on Entity Framework once v4 comes out. As a result, I am looking at what it would take to migrate our application that uses NHibernate for persistence to EF4 using POCO support. In a couple of places we use single table inheritance (also known as Table Per Hierarchy). I have been unable to get i...

Using sql date data type and EF4

I have a table w/ a sql date data type. When I look at the EDM markup, the storage element reflects this. The conceptual entity has a data type of DateTime (there doesn't appear to be a Date data type). When I call save changes and have a DateTime instance associated w/ the entity I want to persist, I get the following error: The conver...

Entity Splitting with Code Only

Is their a way using Entity Framework Code-Only to have an entity that has fields from two tables if both tables don't contain the primary key? Here is an example. public class BlogPost { public int PostID { get; set; } public String PostBody { get; set; } public int UserID { get; set; } public string Username { get; se...

How can I add constraints to an ADO.NET Entity?

I know how to mark a group of fields as primary key in ADO.NET entities but i haven't found a way to declare unique constraints or check constraints. Is this feature missing on the designer or on the framework? Thanx. ...

Silverlight 4.0 + MVC 2.0 + WCF RIA Services + EF 4.0 = Load Error

I'm trying to buid a site with the following: VS 2010 (for the updated WCF RIA Services) Silverlight 4.0 (packaged with WCF RIA Services). MVC 2 EF 4.0 I am setting it up so that the public facing pages will be html from MVC, but the administration portion will be a silverlight navigation application using using WCF RIA Services for ...

EF4 POCO one to many Navigation property is null

I'm using VS2010, EF4 feature CTP (latest release), and POCO objects, such as the example below: class Person { public int ID { get; set; } public string Name { get; set; } public virtual IList<Account> Accounts { get; set; } ... } class Account { public string Number { get; set; } public int ID { get; set; } ... } For the sak...

Using an Interface with a navigation property

I am trying to setup a project using Entity Framework 4, POCO, and Code-Only. Is it possible in entity framework for type of a navigation property to be an interface? I have a "Task" class. A Task can be assigned to a user or a group each of which are represented by a separate class and stored in separate tables. The classes look som...

EF4 POCO - Updating a navigation property

I have a Recommendation object and a FeedbackLevel object and the FeedbackLevel object is a navigation property inside a Recommendation object Recommendation int EntityKey; FeedbackLevel Level; Inserting a new one works just fine with AddObject(). Here's what I'm trying with the update, which doesn't work. recommendation.Level = m...

Retrieve only base class from Entity Framework

If I have three classes in entity framework. class Base {} class Left : Base {} class Right : Base {} and I call DBContext.Bases.ToList(); This returns all instances of Base fully typed into their associated inherited types, as some people have noticed, the performance of EF on large inheritance structures is not great to say the l...

Entity Framework 4.0: Why Would One Use the Code Generated EntityObjects Over POCO Objects?

Aside from faster development time (Visual Studio 2010 beta 2 has no T4 templates for building POCO entity objects that I'm aware of), are there any advantages to using the traditional EntityObject entities that Entity Framework creates, by default? If Microsoft delivers a T4 template for building POCO objects, I'm trying to figure out w...

Using ADO.net Entity Framework 4 with Enumerations? How do I do it ?

Question 1: I am playing around with EF4 and I have a model class like : public class Candidate { public int Id {get;set;} public string FullName {get;set;} public Gender Sex {get;set;} public EducationLevel HighestDegreeType {get;set;} } Here Gender and EducationLevel are Enums like: public enum Gender {Male,Female,Undisclosed} pub...

named connection not found (Entity framework problem)

I'm building multi-project Application where some UserControl, the user control has a Entitymodel object (myDBContainer db = new myDBContainer()), when i drop my user control on my a form i got the following designer error The specified connectionis either not found in the configuration, not intended to be used with the entityc...

'Generic' ViewModel

Using EF 4, I have several subtypes of a 'Business' entity (customers, suppliers, haulage companies etc). They DO need to be subtypes. I am building a general viewmodel which calls into a service from which a generic repository is accessed. As I have 4 subtypes, it would be good to have a 'generic' viewmodel used for all of these. Probl...