Questions tagged [entity-framework-4.3.1]

Entity Framework 4.3.1 is a bug fixing patch release for Microsoft Entity Framework that includes some bug fixes to the 4.3 release.

Entity Framework 4.3.1 is a bug fixing patch release for Microsoft that includes some bug fixes to the 4.3 release.

The changes in 4.3.1 compared to 4.3 include:

  • Templates for using with Model First and Database First have been renamed from ADO.NET DbContext Generator to EF 4.x DbContext Generator to easily distinguish between the EF 5.x DbContext Generator that is to be used for EF 5 applications.
  • Added the ability to enable Code First Migrations against an existing database. Once this migration is generated Code First Migrations will correctly detect and scaffold changes to the model. It is now possible to use the –IgnoreChanges to tell Code First Migrations not to scaffold any code for this initial migration (i.e. ‘Add-Migration InitialMigration –IgnoreChanges).
  • includes LocalDb rather than SQLEXPRESS. The EntityFramework package will now check which database is available when the package is installed and use a configuration file setting to set the default database server that Code First databases will be created on. If SQLEXPRESS is running, it will be used. If SQLEXPRESS is not available then LocalDb will be registered as the default.
  • Fixed issue where TPC mapping in Code First was generating “Unknown Columnname” exceptions when accessing the database.
  • Fixed issue where hard coded column data types were not honored in generated databases. If you used the Column data annotation or HasColumnType Fluent API method to hard code a column data type (i.e. xml, money, etc.), this data type was not used when creating the database.
  • Fixed issue preventing decimal columns from being configured with the ‘Identity’ store generated pattern.
  • Better exception message when context/database initialization fails due to connectivity issues with the database.
  • Enabled support for configsource in configuration files when using Code First Migrations.
  • Fixed issues using Moq with DbContext.

Entity Framework 4.3.1 was released on February 29th, 2012.

Resources

16 questions
21
votes
3 answers

EF 4.3.1 and EF 5.0 DbSet.Local is slower than an actual Database query

I've got a database with a table of about 16,500 cities, and an EF Data Model (Database-First) for that database. I preload them into memory with the code: Db.Cities.Load() ...then when it's time to use them, I've tried each of the following…
8
votes
3 answers

How to reduce number of injected dependencies on controller

I am using MVC3, Entity Framework v4.3 Code First, and SimpleInjector. I have several simple classes that look like this: public class SomeThing { public int Id { get; set; } public string Name { get; set; } } I have another entity that…
7
votes
1 answer

Entity Framework 4.3.1 -> 5.0 Exception: "EntityType has no key defined. Define the key for this EntityType."

In Entity Framework 4.3.1 I had the following Models, and they worked fine: public class BaseUser { [Key] [MaxLength(100)] public string Username { get; set; } } [Table("AppUser")] // Ensures EF Code First uses Table-per-Type public…
Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
7
votes
1 answer

Why would a datetime prevent a navigation property from getting loaded?

I am using Entity Framework 4.3.1 using the DbContext POCO approach against a SQL Server 2012 database. I have just two tables in the database and they look like this: NOTE: There are no foreign keys specified in the database at all - I am only…
6
votes
2 answers

Is it possible to stop Entity Framework "fixing up" the relationships after SaveChanges?

I am getting this exception from Entity Framework 4.3.1 (incidentally from an ASP .NET MVC 3 web application built in Visual Studio 2010 against .NET 4): System.InvalidOperationException: The changes to the database were committed successfully, but…
kmp
  • 10,535
  • 11
  • 75
  • 125
5
votes
3 answers

Entity Framework - closure of Object Contexts

After using EFProfiler (absolutely fantastic tool BTW!) for profiling a few of our Entity Framework applications, it seems that, in most cases, all of the Object Contexts are not closed. For example, after running it locally, EF Profiler told me…
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
3
votes
2 answers

Using EntityFramework dbContext to get records with count in another table

I am using EntityFramework 4.3.1 and Database first with dbcontext. Let's say I have 2 tables: Customer and Order with a 1 to many relationship between Customer and Order. I have two queries that I want to run using EntityFramework to get back…
Stoop
  • 1,235
  • 3
  • 17
  • 23
1
vote
1 answer

Code compiles, yet DbContext.SaveChanges() ultimately tries to cast [...]Generic.List`1[x]' to type 'x'

I have just completed re-factoring some code, and I now have this error when saving the DbContext following some calculation code that shouldn't have been affected by the changes I've just made. The error is: {"Unable to cast object of type …
1
vote
1 answer

EF 4.3.1 Migration - how to downgrade a production database?

I have been looking at how to produce a downgrade in EF 4.3.1 Migrations, and all I have found is only about scripting (like this EF 4.3 Migration - how to produce a downgrade script?) To upgrade my user's production database I call the method…
1
vote
1 answer

How to avoid duplicate insert in Entity Framework 4.3.1

I have a small model created using code-first approach - a class City which contains only information about city name. public class City { public City() { Posts = new List(); } public City(string cityName) { …
1
vote
1 answer

Entity Framework 4.3.1 Table Per Type Code First generates a different schema in SQL Server Express 2008 and SQL Server 2008R2

I'm using EF CodeFirst to generate quite a large schema including TPT tables, e.g. [Table("MissingReplacementDongles")] public class MissingReplacementDongle : ReplacementRentalDongle { public virtual bool OriginalStolen { get; set; } } public…
0
votes
1 answer

EF 4.1.3 Implenting Rowversion for Concurrency is not working

I have got a BaseEntity class which contains a, byte array called stamp, id and state, which every Entity inherits from I am mapping the stamp to Property(t => t.Stamp).IsRequired().IsRowVersion(); this is set in BaseEntityConfiguration which…
0
votes
1 answer

How to add a text box and a column to save text in it dynamically in ASP.NET MVC 3 application

I have to add a button which when clicked creates a new text box where I can add some text and save it in database. For example- I click button thrice it will create 3 text boxes and 3 new columns in database to save them. Application is in…
0
votes
0 answers

Why is cascade delete not on by default for this relationship?

I have a 1 to many relationship between LabelLineItem and DespatchPart. I can't understand why cascade delete is off for this relationship. There is no relationship defined in the context using the fluent API. There is no LabelLineItems navigation…
0
votes
0 answers

Add entity from another context to context and attach existing object graph entities so no duplicates

I have a method that creates a new entity with a pretty complex object graph that may or may not contain existing entities in it. That method manages its own context. It returns the entity which is consumed in a method on a different class that…
lintmouse
  • 5,079
  • 8
  • 38
  • 54
1
2