entity-framework

Entity Framework issue - "Mixed mode assembly...cannot be loaded in the 4.0 runtime without additional configuration information"

I have a UI & Library project for the solution where I'm having the problem. The library project uses Entity Framework & the unit tests work OK with it. The project is a C# 4.0 WPF application. To try to get a basic EF line of code working I copied the connection string from the Library project app.config to the UI project app.config....

Update function import not displaying in context file

Hi, I am using EF4 and I used the POCO entity generator to create my entities. I have a stored procedure called UpdateApplicationState. I pass it just 2 parameters called ApplicationID and ApplicationStateID. It returns nothing so I set the return type as None. I only want it to update the application state ID, nothing else. When I...

Entity Framework: delete record with its sub-records

I have a table with 3 columns: ID, Name, ParentID. How can I delete a specific record with all its children (n levels deep)? Using Entity Framework 3.5. ...

Entity framework POCO template missing (i am using visual studio 2010 professional )

Hi When i create a .edmx and i hit "Add code generation item" the POCO template is missing, i can only see Entity Object Generator and Sel-Tracking Entities Generator. What am i missing? ...

Difference between NHibernate SessionFactory and EF 4.0 ObjectContext

In NHibernate SessionFactory is said to be a heavy object and it is suggested that SessionFactory should be created once in application life span. However once we get handle to SessionFactory, we do call open() on it before doing any DB operation. In EntityFramework we need to create an object of ObjectContext every time before doing an...

does EF 4 have Audit and Logical Deletes support built in?

Does EF 4 have built in audit / logical delete support? After using SubSonic and getting use to how nicely this was handled automagically I was hoping I might have the same luck with EF 4 but haven't found any documentation. ...

Entities and multiple databases

Hi, We've got the following scenario: Central Database (replicated across multiple servers) Client Database 1 Client Database 2 The Central db has Users and Roles amongst other things The Client dbs have similar tables to each other but with some fields tweaked - contact, address, etc... At present, each client db has its own user/r...

VB.Net Search namespace for a generic type (Reflection)

Hi, I'm attempting to dynamically register entities and configurations with a context (ef4 code-only) I would normally do: Private Shared Sub ConfigureDatabase(ByRef Builder As ContextBuilder(Of ContextExtension)) 'Load configurations for each of the tables (Entity sets) in our database... ConfigureEntity(Builder, New ContactConfi...

Can one implement an interface property on an Entity Object interface?

I'm using Entity Framework and I have created an interface for lease transactions: public interface ILeaseTransaction { int ID { get; } DateTime Date { get; } decimal Amount { get; } } Then to implement the interface on the Entity Object I created an empty partial class: public partial class Type1LeaseTransaction : ILease...

Do we still need stored procedures when using compiled queries?

When using compiled queries in entity framework (or linq-to-sql) in combination with SQL Server, is there actually still any performance benefit in using stored procedures? Compiled queries will be cached as parameterized queries, so performance should be near equal to stored procedures. Is there any situation where stored procedures wo...

Entity framework: Best practice for case (as in pascal-case) in database tables/columns

In C# I always use PascalCase for properties (best practice, right?), for databases i always use lowercase for tables and columnnames (best practice, right?) When I generate classes from tables using entity framework, i get lowercase property names in C#, so I manually refactor the case in C#. I wondered, is it best practice to use Pas...

put just the key type (id) or the class type for FK in entities, pros and cons

I've seen 2 types of entities, like this: public class Person { public int Id {get;set;} public string Name {get;set;} public Country Country {get;set;} } and like this: public class Person { public int Id {get;set;} public string Name {get;set;} public int CountryId {get;set;} } I think that the 2nd approac...

MVC 2 custom data annotations on partial entity class property not registering validation error?

Hi All, I have a data entity class which I have added a property to using a partial class: [MetadataType(typeof(LocaleMetaData))] partial class Locale { public sealed class LocaleMetaData { [Required(AllowEmptyStrings = false, ErrorMessage = "A locale must have a descriptive ...

Append OR subquery in Linq

I am trying to build a simple search against some entities (EF4, if that makes any difference). Passed into my search query is a list of criteria objects. The crieteria object looks like this: public class ClaimSearchCirtieria { public Guid? FinancialYear { get; set; } public bool AllClaimants { get; set; } public IList<Guid...

One-to many relationship not working - Entity Framework

Hi All, I'm having a problem with creating a one-to-many(or one-to-one?) relationship in entity framework (3.5 I believe). Example tables/models: Settings: SettingsID pk int not null SettingsName varchar(250) null SettingsTypeID fk int null SettingsType: SettingsTypeID pk int not null SettingsTypeName varchar(250) ...

Table foreign key / association to itself?

Hi, I've got a table that stores inventory for a store that looks like this InventoryId int ParentId int ShortDesc int ... [other product data] ... A TShirt will exist in the table with a ParentId of -1. Any variations of size and colour will exist in the same table with the original parent InventoryID in the ParentID f...

Linq-to-SQL or Linq-to-Entities with ASP.NET 3.5 and SQL Server 2005

I am starting a new project using C# and ASP.NET 3.5 with SQL Server 2005, and I am trying to decide which ORM is the best to use between LinqToSQL, LinqToEntities, or NHibernate. Ideally I would like to use the preferred Microsoft best practice; but I need to use a solution that will provide performance comparable to using stored proce...

Entity Framework - Auditing activity.

My database has a 'LastModifiedUser' column on every table in which I intend to collect the logged in user from an application who makes a change. I am not talking about the database user so essentially this is just a string on each entity. I would like to find a way to default this for each entity so that other developers don't have t...

How do I generate a dynamic connection string in Entity Framework 4?

Is it possible to choose a specific database that will be used with the entity framework? At this time, I use the connection string in the Web.Config as database authentication. I have twelve databases, each of them has the same structure and the same stored procedure. There is one database for each client. When a client wants to login...

Changing connectionstring for entity framework after IIS7 MVC Publish results in metadata error

I built this app with Web Developer Express 2010 using SQL Server Express 2008. I downloaded mdf/log files from my server to my local and attached them as a database with SQL 2005 compatibility. I'm now trying to publish to my production server. The server is using SQL Express 2005 and Windows Server Web. I tried to change out the web.c...