entity-framework

Deleting Entity in Entity Model gives Foreign Key errors

Deleting Entity in Entity Model gives Foreign Key errors Error 92 Error 3013: Problem in Mapping Fragments starting at lines 5023, 5183, 5507: Missing table mapping: Foreign key constraint 'FK_TableName' from table TableName(ID) to table Other_TableName (ID): no mapping specified for the table TableName C:\MyDirector\MyModel.edmx ...

Convince entity context (EF1) to populate entity references

I have an entity with self reference (generated by Entity Designer): public MyEntity: EntityObject { // only relevant stuff here public int Id { get...; set...; } public MyEntity Parent { get...; set...; } public EntityCollection<MyEntity> Children { get...; set...; } ... } I've written a stored procedure that retu...

Entity framework, getutcdate()

Hi, Can I use the SQL-function getutcdate() from entity framework to set a date field in the database when saving an entity object? regards Freddy ...

Entity Data Model Associations and MVC 1 .NET giving NULL on Associated objects but allowing Linq to Entities Filtering

I have a EDM that was wizard generated from an SQL 2005 Express database. For example, I have a table named Projects with a relationship to a table named People. Projects have two relationships on the People table primary key as foreign key in the People table (ChamipionID and LeaderID). I have cleaned up all of the names for the Enti...

C# How To Update Entity Model Connection String

This is my first WinForm application using the Entity Framework and I have to be able to update the connection string for the entity model I created on the fly and in my app.config file I have the following connectionString: <add name="NCIPEntities" connectionString="metadata=res://*/NCIPModel.csdl|res://*/NCIPModel.ssdl|res://*/NCIPMod...

Is the Entity Framework compatible with SQL Azure?

I cannot get the Entity Framework to work against SQL Azure. Is this just me or is it not intended to be compatible? (I have tried the original release of EF with VS2008 as well as the more recent VS2010 Beta 2 version) To check this I created the simplest scenario possible. Add a single table to a local SQL Server 2008 instance. The ta...

How to add view to Entity framework Entity model?

When I create a view in database, then I want to add it to EF Model. In the list to add object, I can see and select the view, but nothing happened when try to add it to Model. It is because there is no Key for the view. How to add view to Model? ...

Reusing part of the query with joins

I need to implement 3 public methods that all rely on the same initial join. Would a solution like the one described below work? The code below is an example, the real stuff is much more complicated, that's why I want to reuse it. private Tuple<Customer,Order> GetCustomerOrders() { from c in customers join o in orders o...

Linq, emulating joins, and the Include method

Hello, I'm looking into an issue that is related to... http://stackoverflow.com/questions/416847/join-and-include-in-entity-framework Basically the following query returns the list of "Property" objects the current user has permissions ( ACLs ) to view. IQueryable<Property> currPropList = from p in ve.Property ...

Get Database Table Name from Entity Framework MetaData

I'm trying to figure out a way to get the underlying SQL table name for a given entity type. I've experimented around with the MetadataWorkspace queries and while I can get lots of information from the object or the storage space, I can't seem to figure out how to map between the two. So say I have a type in the object model called Look...

Database independence

We are in the early stages for putting a design for a big business application that will have multiple modules. One of the requirements is that the application should be database independent, it should support sql server, oracle, mysql and DB2. From what I have read on the web is that database independence is a very bad idea, it would r...

Computed columns: SQL or Locally in Entity Framework?

Hello! I have some computed-columns of two types: Computed columns based on columns in current table (i.e. Price * Tax) Computed columns based on other columnes (i.e. Price * fn_GetTax(OrderId)) Would you say it's better to use these columns in CLR on the client only and then save from the server the calculation and transferring per...

Entity Framework using Generic Predicates

I use DTO's to map between my Business and Entity Framework layer via the Repository Pattern. A Standard call would look like public IClassDTO Fetch(Guid id) { var query = from s in _db.Base.OfType<Class>() where s.ID == id select s; return query.First(); } Now I wish to pass in filtering criteria from the bu...

What is the best practice when the database schema changes in entity framework?

I am using Entity Framework to do the ORM in .NET project. The problem I am facing is that when the database schema changes, there is no proper mechanism to update the edmx file. For example, If there is a column called "Salary", and I change it to "EmpSalary", then when I update the edmx from visual studio and it shows me two columns ...

Materilizing related entities from SPs using EF Extensions

I have a stored procedure that returns a collection of my entity class objects. Since I want my navigation properties populated as well I'm using EF Extensions and I've written my own Materializer class. But. My entity class has a navigation property of Type that points to a different entity. Stored procedure of course returns an ID fro...

Entity Framework - MySQL - Datetime format issue

Hello; I have a simple table with few date fields. Whenever I run following query: var docs = ( from d in base.EntityDataContext.document_reviews select d ).ToList(); I get following exception: Unable to convert MySQL date/time value to System.DateTime. MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time v...

Entity framework 3.5, mapping stored procedure results to custom entity

I tried to follow this link to map stored procedures to Custom Entities, but when I did so I could no open the EDMX file in the VS 2008 designer. so looks like it is causing some issues. Does anyone know how to map Stored procedure results to custom Entities in Entity Framework? ...

Entity Framework Attaching a Persisted Object to the New Object

I am trying to perform a very simple task which is "Add the user with role in the database". The roles are already populated in the database and I am simply adding the role to the User roles collection but it keeps throwing the following exception: The EntityKey property can only be set when the current value of the property is null. ...

Load a property in a batch in ADO.Net Data Services in Silverlight

I'm using ADO.Net Data Services (Astoria) in Silverlight 3 and I want to delay loading properties on an entity until after the initial load. However, when I'm ready to load them I'd like to batch the load requests together. // this is what I want to avoid var c = (from c in ctx.Customers.Expand("Address,Phone,Email") where c.I...

Custom validation with Data annotations

Hello I'm using dataannotations to check data thats being entered, but I'm stuck when it comes to more custom way to validate data. I need to run queries against database to see if stuff exists there or not, and then report back to user if a "custom db-check error" appears, such as "The Companyname already exists" How can I implement...