entity-framework

.Net Entity Framework get reference from N->1 relation

Hi, I'm having a ridiculous little problem. I have generated my model classes in visual C# Express 2010 but in a 1(parent)->Many(children) relation I can only access the children through a vector in the parent. I want to also be able to access the parent through a child. Does anyone know if this is a setting problem with a simple check...

How to map Stored Procedure params when using Stored Procedure for CRUD?

Suppose I have a table like: Person(ID, Name, DOB, ...) I use EF to create model with VS2010. Then I want to use SP for CRUD. say my SP for insert like: Create PROCEDURE [dbo].[Person_Add] (@DOB datetime, @NAME varchar(10)= null,@PersonType as int) AS Begin ... End Param @PersonType is someting I want to use in SP for som...

Potential for SQL injection here?

This may be a really dumb question but I figure why not... I am using RIA Services with Entity Framework as the back end. I have some places in my app where I accept user input and directly ask RIA Services (and in turn EF and in turn my database) questions using their data. Do any of these layers help prevent security issues or should ...

implement N-Tier Entity Framework 4.0 with DTOs

Hi, I'm currently building a web based system and trying to implement N-Tier Entity Framework 4.0 with DTOs in a SOA Architecture. I am having a problem understanding how I should implement the Data Access Layer (DAL) , the Business Logic Layer (BLL) and the Presentation Layer. Let’s suppose that I have a “useraccount” entity has the ...

SQL table relationship not showing up in visual studio

Hey, I made several tables and relationships using SQL server manager. I then imported them to visual studio and it all appeared in the correct form, except one of the relationships did not appear. I have checked everything I could think of and it is the exact same as the other relationships. If you know anything I can check, I would app...

Entity Framework 4.0 Mapping POCOS with different property names from db fields names

Hi, I'm a newbie to ADO.Net Entity framework 4. I have a set of pocos which I need to map to a legacy database. The problem is that the db field names are different to the poco property names. eg. db field name = 'cusID' and poco property = 'CustomerID'. What is the best way to map these? ...

How to insert a large number of records quickly using ADO.Net Entity Model?

I am using the ADO.Net Entity Model. Everytime I create a record, I am calling _entity.AddToTable(object); _entity.SaveChanges(); What is the fastest way of inserting the data? Is there any "batch" or "SqlBulkCopy" option for entity model? ...

How to use FormView in order to insert complex entity framework objects

Hello, I'm trying to use formview in order to do insert of a new entity object (called Customer) Customer has a reference to another entity called Address. How can I fill both of them in the same formview? Thanks. ...

Entity Framework Error: NavigationProperty

Hi, I've been trying to fix this issue I get when I add a new entity framework edmx file to my project and try to make it generate my tables, procs and views. When I build it it gives me this error on my drawer table: Error 601 Error 6017: The NavigationProperty 'Drawer' on the type 'DrawerCompany' is the source of a generated proper...

Are any major applications using Entity Framework?

I'm investigating the use of Entity Framework in an upcoming project, but I have some concerns about the maturity and market adoption of the product. Are there any high profile web sites or applications using the product? Are there any significant open source projects that have picked it up? ...

POCO inherited type could not pass addObject method

Hi all I am using a POCO class name "Company" generate from the T4 POCO code generator to create a derived class - name "CompanyBO" by "public class CompanyBO:Company", but when i call addObject method: public void Delete(T entity) { CustomerWebPortalEntities entities = new CustomerWebPortalEntities(); ...

What are the pros and cons of "include foreign key columns in the model" option in EF 4

With EF4 comes a new feature "Include foreign key columns in the model". What was the motivation behind adding this feature, and are there any particular gotcha's with either leaving it off, or turning it on when generating a model from an exisiting database? ...

Tracking user changes in ASP.NET MVC

I have a requirement to track what authenticated users change with regards to the data when logged in. I don't need to track what pages they look at although that could be very useful in future. I have thought about saving the User Guid but that seems very clunky. I do need to do simple stuff like old value and new value. I am using the...

Entity Framework: Auto-updating foreign key when setting a new object reference

Hi, I am porting an existing application from Linq to SQL to Entity Framework 4 (default code generation). One difference I noticed between the two is that a foreign key property are not updated when resetting the object reference. Now I need to decide how to deal with this. For example supposing you have two entity types, Company and...

Help decoding MSDN Dynamic Data Article

I'm trying to run through this msdn article: http://msdn.microsoft.com/en-us/library/dd723645.aspx One of the steps is: In the class file for the page, change the base class from UserControl to EntityTemplateUserControl. Nowhere is it made clear what page is being referenced. Can someone help me? I don't see any relevant class in t...

Entity Framework - An object with the same key already exists in the ObjectStateManager

Hey all, I'm trying to update a detached entity in .NET 4 EF: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save(Developer developer) { developer.UpdateDate = DateTime.Now; if (developer.DeveloperID == 0) {//inserting new developer. DataContext.DeveloperData.Insert...

Unable to use stored procs in a generic repository for the entity framework. (ASP.NET MVC 2)

Hi, I have a generic repository that uses the entity framework to manipulate the database. The original code is credited to Morshed Anwar's post on CodeProject. I've taken his code and modified is slightly to fit my needs. Unfortunately I'm unable to call an Imported Function because the function is only recognized for my specific ins...

Entity comments are removed upon saving of updated model

To clearify: I use the POCO generator so that the entities are not tightly bound to the EF implementation. In my entities, I tend to add comments for the properties but as I update the model and save it, all the comments are removed. How can I prevent this behavior? ...

Entity Framework - adding new items via a navigation property

I have come across what appears to be very peculiar behaviour using entity framework 4.0. I have a User entity, which has a Company (A Company has many Users). If I do this, everything works as expected and I get a nice shiny new user in the database: var company = _model.Companies.First(); company.Users.Add(new User(1, "John", "Smith...

what possible workarounds are there for "only parameterless constructors are support in Linq to Entites"

In my query I need to return instances of a class that doesn't have a default constructor (specifically this is in a custom Membership provider, and MembershipUser is the culprit) var users = from l in context.Logins select new MembershipUser( Name, l.Username, // username l.Id, // provider key l.Mail...