I'm been looking around and trying to see if the Entity Framework 4 will run under Visual Studio 2008, but can;t find any references to it.
Can you get EF4 working on VS2008?
Hi,
My UPDATE and DELETE logic are in stored procedures. I've built an entity framework model with mappings to these procedures.
In spUpdate I return the new timestamp column so the EF could detect concurrency conflicts. It works fine.
I have a problem with the spDelete because I don't see mappings for return values in the "delete function" row.
How to check concurrency in this example?
I've had an entity framework model working for some time. Yesterday, it suddenly started complaining about a foreign key relationship issue during an insert. I've checked the fields and can do a manual insert using the exact field values. But the EF continues to complain. Any ideas what could have happened?
I'm brand new to the Entity Framework and trying to learn all it can offer. I'm currently working my way through the MVC Music Store tutorial which includes the following code:
public ActionResult Browse(string genre)
{
// Retrieve Genre and its Associated Albums from database
var genreModel = storeDB.Genres.Include("Albums")
.Single(g => g.Name == genre);
return View(genreModel);
}
as I'm working in VB I converted it like so:
Function Browse(ByVal genre As String) As ActionResult
'Retrieve Genre and its Associated Albums from database
Dim genreModel = storeDB.Genres.Include("Albums"). _
Single(Function(g) g.Name = genre)
Return(View(genreModel))
End Function
The problem is I'm getting the following exception:
Invalid column name 'GenreGenreId'.
Which I know is true, but I can't for the life of my work out where it's getting 'GenreGenreId' from. Probably a basic question but I'll appreciate any help in the right direction.
As per requested here is the source for my classes:
Album.vb
Public Class Album
Private _title As String
Private _genre As Genre
Private _AlbumId As Int32
Private _GenreId As Int32
Private _ArtistId As Int32
Private _Price As Decimal
Private _AlbumArtUrl As String
Public Property Title As String
Get
Return _title
End Get
Set(ByVal value As String)
_title = value
End Set
End Property
Public Property AlbumId As Int16
Get
Return _AlbumId
End Get
Set(ByVal value As Int16)
_AlbumId = value
End Set
End Property
Public Property GenreId As Int16
Get
Return _GenreId
End Get
Set(ByVal value As Int16)
_GenreId = value
End Set
End Property
Public Property ArtistId As Int16
Get
Return _ArtistId
End Get
Set(ByVal value As Int16)
_ArtistId = value
End Set
End Property
Public Property AlbumArtUrl As String
Get
Return _AlbumArtUrl
End Get
Set(ByVal value As String)
_AlbumArtUrl = value
End Set
End Property
Public Property Price As Decimal
Get
Return _Price
End Get
Set(ByVal value As Decimal)
_Price = value
End Set
End Property
Public Property Genre As Genre
Get
Return _genre
End Get
Set(ByVal value As Genre)
_genre = value
End Set
End Property
End Class
Genre.vb
Public Class Genre
Dim _genreId As Int32
Dim _Name As String
Dim _Description As String
Dim _Albums As List(Of Album)
Public Property GenreId As Int32
Get
Return _genreId
End Get
Set(ByVal value As Int32)
_genreId = value
End Set
End Property
Public Property Name As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Description As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
Public Property Albums As List(Of Album)
Get
Return _Albums
End Get
Set(ByVal value As List(Of Album))
_Albums = value
End Set
End Property
End Class
MusicStoreEntities.vb
Imports System.Data.Entity
Namespace MvcApplication1
Public Class MusicStoreEntities
Inherits DbContext
Public Property Albums As DbSet(Of Album)
Public Property Genres As DbSet(Of Genre)
End Class
End Namespace
Can someone point me to a good tutorial explaining the Entity Framework using an XML file instead of a database?
I have seen some good tutorials with SQL databases, but I can't make the leap to an XML file.
Thanks!
Is it possible to pass a SQL script to some method that Entity Framework has to run it against my model? e.g. equivalent of:
context.ExecuteStoreCommand(<tsql script path>);
Background: I want a way to reset the database during unit tests, and making a call to run the EF generated TSQL script (from Generate Database from Model) seems one way to achieve this.
Hello All:
I am using entity framework 3.5 for my application.
I want load data based on some condition e.g.
var data = from e in context.Employee.Include("Employee.Projects") where e.IsActive select e;
Using this, I will get all the Employees which are active with their project details. But I want to load only those projects which are active. So, how to load only active projects using the query?
Thanks
Ashwani
Hi,
In Entity Framework (VS2010) how do I create an association to/from the same table? (a many-to-many is what I want)
Background - I was expecting under the bonnet a NODE and RELATIONSHIP table, where the latter has a parent_node_id and a child_node_id (i.e. pointing back to the NODE id column). I can't seem to get the designer to add it...
Any experiences on how to document Entity Framework 4 based Database projects?
There is the Document and Summary properties on the Entities, but if we want to regenerate the model from the database at some point, it will be lost!
Is there some way to map documentation data inside SQL to the Entities in the EDMX file so it is safe.
Suggestions of other best practices? Ideally I want to be able to augo generate html/helpfile documentation from the DB when we deploy.
Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are?
So I'm starting to look into EF and POCO.
From my understanding, the entity generated by EF is not pure POCO since it inherit from EntityObject.
But are they PI? It seem to me that they don't have any persistence awareness in them, or there is something in the EntityObject that makes them PI?
Let's say we have the "EntityCollection products".
Then the following doesn't work:
foreach (var product in products)
{
product.LastUpdate = DateTime.Now();
}
As you can also not index an EntityCollection, how do you modify an entity in en EntityCollection?
I have an 'overlay.dtd' file with a line like <!ENTITY myentity "myvalue">.
At the top of my xul file I have <!DOCTYPE overlay SYSTEM 'chrome://myaddon/locale/overlay.dtd'>.
In my xul file, I have <script src='myscript.js'>.
I want to know if there is any way to access 'myentity' from the script.
alert("&myentity;") just alerts "&myentity;"
Hello Guys!
I'm mapping a set of tables that share a common set of fields:
So as you can see I'm using a table-per-concrete-type strategy to map the inheritance.
But...
I have not could to relate them to an abstract type containing these common properties.
It's possible to do it using EF?
BONUS: The only non documented Entity Data Model Mapping Scenario is Table-per-concrete-type inheritance http://msdn.microsoft.com/en-us/library/cc716779.aspx : P
Hi,
I have .net 3.5 SP1 and VS 2008 SP1 installed in my machine. But what should I further install to create an Entity framework project. Is there any other add ons that is needed?
I'm well aware that similair topics have been brought up before
e.g. http://stackoverflow.com/questions/1639043/entity-framework-4-vs-nhibernate
But instead of arguments like:
NHibernate have been around longer and is more mature
EF4 is drag n drop and not enterprisy
EF4 and LinqToSql are ...
I would like to see a more detailed list of features that you consider missing from EF4.
Personally, I think the lack of enum support is the biggest drawback of EF4.
Hi,
I've described my model using an Ado Entity Data Model file (*.edmx), and i wish now to generate my db schema and tables from it. Is it possible?
Thanks
I'm trying the database first approach by creating an ADO.NET Entity Data Model using the Wizard with the Adventureworks2012 DB.
Testing DB connection works, and the connection string is added to the App.Config.
I'm selecting all the tables except the ones marked as (dbo) AWBuildVersion, DatabaseLog, and ErrorLog.
When the Wizard finishes the .edmx file is blank, and if I view the file in XML view the EntityContainer is empty.
I'm using VS 2010 & .NET Framework 4.0
I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error:
Error 1 Error 11010: Association End 'OperatorAccess' is not mapped. E:\Visual Studio\projects\Brandi II\Brandi II\Hospitals.edmx 390 11 Brandi II
Not sure what it is I am doing wrong
I have
[Person]
PersonID, EmailAddress, FirstName, LastName
[OnlineAccount]
OnlineAccountID, PersonID, Nickname
Each person is allowed to have 0-* OnlineAccount.
In entity framework with C#, how do I select the top 5 Person that has the most accounts?
These web articles uses separate Save() and Update() methods in the repository pattern.
I am using repository pattern.
How can I write a SaveOrUpdate() method in Entity Framework with the help of ObjectContext and in Linq-To-SQL with the help of DataContext?
That is, how can I write a single method that shall do both save and update job?
When use entity framework for DAL tier, VS 2010 can create edmx for each database.
Question:
If I have a database with many tables, should I create only one edmx for all tables or mutiple edmx files? for example, maybe all security tables for one edmx file, other tables for another edmx file. If there is more than one, then in other tiers, there will have more then on ObjectContext in code for business logic.
Which one it the best solution for this case?
Hi .. I intend to extend the constructors of some of the entities in my Entity Framework (4).
However how do I ensure that my constructor is run after the model has run its.
i.e. I want to ensure that the the object holds the data from the database before I work on it in my constructor.