entity-framework

Entity Framework CTP4 Mapping Error

Hi. I was messing around with CTP4 trying to get a feel of how mapping works and i've got this error that i can't figure out. {"A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'OwnerID'."} I read around that this was due to my pk being auto generated, but i do not specifically s...

ASP .NET Membership with Entity Framework

How is everyone designing their EF models when using the built in ASP .NET Membership functionality? I have many entities (blog posts, comments, photos, etc.) which have a user id associated with them. I currently have a User model that maps to the aspnet_User table, but there is lots of sketchy code juggling around both the MembershipU...

Entity Framework CTP4: where to put SetInitializer?

I am attempting to add Entity Framework, code first, to an MVC application that's been running with test data, using the CTP4 preview. I am currently getting this error: The model backing the 'SchedulerContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializ...

Can Entity Framework be used to generate SQL Server Compact database

I created a project as described here using Visual Studio 2010 and .NET 4 (Win7/x64). Once I've change the platform target to 'Any CPU' the sample project works. However, if try to generate a model from entity data model (right-click the model and select 'Generate Database from Model'), I get the following error. Could not find the appr...

Multiple relationships with lookup tables in Entity Framework

The context of the question is ASP.NET MVC2 / EF4. I have a number of lookup tables in the database which have previously been programmatically referenced, each from a number of other tables... So there might be a country table with country-id shortcode, desc, and half a dozen tables that have a countryid in them. Repeat for 5 or 6 other...

Does Linq to Entities throw SqlExceptions?

Hi! I'm using linq to entities, and my entity model is sitting on top of MSSQL database. I'm wondering if linq to entities throws SqlExceptions or not. In other words, will the below code catch exception successfully if there was a problem connecting to the database? If it doesn't, what's the best way to handle exceptions when using lin...

Return all row having a maximum value

Hi! I'm using entity framework to connect the database. I've a table(Let's call it "File") that haves several fields: ID, Version, XYZ Primarky key is based on ID AND Version. so I can have several line with the same ID but different version(and inversly). The question is: How can I, with a LAMBDA expression, ask my Entity Framewor...

Metadata related exception when using Entity Framework 4

I use VS 2010 Ultimate. I created an 'asp.net web application' from scratch, added a 'ADO.NET Entity Model' to my project (EF4). The problem I'm having is that whenever I try and use an EntityDataSource to pull data out of my entity model I am near constantly getting the following error: "The metadata specified in the connection st...

SqlMetal alternative for Entity Framework 4

I used to prefer using SqlMetal to the OR Designer in Visual Studio when generating my Linq2SQL model. So, my question is: Is there an equivalent to SqlMetal for generating EF4 models, i.e. a command-line tool for rebuilding my EF classes in one step? ...

Is it possible to remap a single column, with a special character in it, with Entity Framework Code First?

I have a rather large table of mineral/vitamin definitions (44 columns) and every column name but one is correct. I have a column called [Tryptophan/60] in the SQL database table and I need to represent this in my EF DTO Object MineralDefinition: public class MineralDefinition { public int DefinitionId {get;set;} public string T...

Good field names that work for both Rails and .Net apps

I'm really thinking that in the years ahead, I will be creating internal apps in both Rails and .Net Entity Framework that will need to work nicely again the same SQL Server or MySql database tables. At this point I'm pretty much greenfield in the table designs, so I can name my columns anything I want to. I've studied Rails and .Net E...

How can I efficiently and easily import/export large business data in .NET ?

Hi, What would be the best data format (XML, Database, etc.) for large business data when we want to efficiently and easily load all of it (import) into business objects in .NET ? I want to load all the data in one go and create all business objects. The data must have a kind of a "schema" to enable other people to create it. Also n...

Change the T4 POCO Entity Framework Template to inherit from my base class.

I'm trying to create a solution with layered architecture and self tracking entities. I used the Entity Framework C# POCO Entity Generator i download from Extensions Online Gallery. I separated the context.tt with the entities.tt on they're own class libraries. Mapped the entities.tt to the Model. Now i need to make these classes inherit...

I'm starting a new VB project and I could use some guidance...

Hi - I don't have a specific question here but I'm more looking for some guidance regarding a new software project I'm starting at work. Here is a description of the project: I am refactoring windows software that was written in Visual Basic 6 and uses MS SQL Server for a database. The code is tightly coupled with SQL queries and refe...

How to configure entity framework metadata locations for a web application

Hi, I am trying to configure Entity Framework 4 in the Web.config file using this ConnectionString ... metadata= res://*/CmsEntityDataModel.csdl| res://*/CmsEntityDataModel.ssdl| res://*/CmsEntityDataModel.msl; .... I would like remove the "*" and add the actual path for my dll file. How to find the path fo...

Entity Framework Many To Many Relationship

I'm using the default ASP.NET profile and membership provider. I want to create a ASP List View with the name of the user and their role. When I try using this functionality I get a error: Code behind: public List<aspnet_Users> GetUsers(int startRowIndex, int maximumRows) { this.entities.aspnet_Users.Include("aspnet_Roles").Order...

Trigger stored procedure after SaveChanges in Entity Framework 1.0

Hi all, i have an audit table in SQL server 2008 database which keeps track of all changes made in tables. It does a great job, except it can't catch username of the currently logged user, because my connection string uses one username for all connections. This app is written in ASP.NET MVC, this is why i have username stored in connec...

Entity Framework : implemeting very simple association scenario

I want to implement the below mentioned problem in Entity Framework. I have 2 tables( below are their simplified versions) items table itemId,itemName tags table tagId,tagName my logic is, an item can have more than one tag and a tag can have more than one item related to it, so I have added many to many relation (please correct...

How do I get Entity Framework to only update the Properties modified in the SQL generated?

I am using Entity Framework with the Self-Tracking Entity T4 templates, which by default will generate a SQL Query setting all the properties on the Entity in an UPDATE statement. I only want an UPDATE statement that contains the properties modified. I modified the T4 Template as specified in the book: Entity Framework Recipes: A Probl...

EF4: For a new app, is it better to generate db scripts for an empty db, or generate class from an db with tables in already in place?

For my first app I created the db and the tables it used. I was not impressed that I had to use buddy classes for validation, but at least I know what I am doing now. For my next app, is it worth learning instead how to create db scripts to populate an empty db, and do it that way round? I suspect it is, but let me know what you think. ...