Bagikan melalui


EF5 Beta 2 Available on NuGet

 


The information in this post is out of date.

Visit msdn.com/data/ef for the latest information on current and past releases of EF.


 

A few weeks ago we released EF5 Beta 1, since then we’ve been working to improve quality and polish up the release. Today we are making EF5 Beta 2 available on NuGet.

This release is licensed for use in production applications. Because it is a pre-release version of EF5 there are some limitations, see the license for more details.

 

What Changed Since Beta 1?

Beta 2 is mainly about improving quality, here are the more notable changes since Beta 1:

  • Migrations commands now work in Visual Studio 2010. There was a bug in Beta 1 that caused them to only work in Visual Studio 11 Beta.
  • Moved database related Data Annotations to System.ComponentModel.DataAnnotations.Schema namespace. The annotations that originally shipped in EntityFramework.dll have moved into System.ComponentModel.dll in .NET 4.5. As part of this move, the database related annotations were moved into a .Schema sub-namespace. In EF 5 we made the same namespace change for applications targeting .NET 4.0.
  • Fixed the ‘Sequence contains no elements’ bug that several users reported on Beta 1.
  • Simplified the web.config/app.config settings to register SQLEXPRESS or LocalDb as the default. We added a LocalDbConnectionFactory which makes the config that is created while installing the NuGet package much simpler. See the ‘Visual Studio 11 includes LocalDb rather than SQLEXPRESS.’ point in the next section for more details on how the default database is selected.
  • LocalDb database now created in App_Data directory of ASP.NET applications by default. The new LocalDbConnectionFactory will add LocalDb database files to the App_Data directory when used in ASP.NET applications.

 

EF Power Tools Beta 2 is Coming

Entity Framework has progressed a lot in the last 6 months and we’ve let the Power Tools fall behind. We are working on an updated version at the moment and we’re aiming to have it available in the next couple of weeks.

 

Simplified msdn.com/data/ef

We’ve been doing some work to simplify the main Entity Framework to make it a better starting point for our product. There is still plenty of room for improvement but you should find the site much more useful already.

 

What’s New in EF5?

EF 5 includes bug fixes to the 4.3.1 release and a number of new features. Most of the new features are only available in applications targeting .NET 4.5, see the Compatibility section for more details.

  • Enum support allows you to have enum properties in your entity classes. This new feature is available for Model, Database and Code First.
  • Table-Valued functions in your database can now be used with Database First.
  • Spatial data types can now be exposed in your model using the DbGeography and DbGeometry types. Spatial data is supported in Model, Database and Code First.
  • The Performance enhancements that we recently blogged about are included in EF 5 Beta 1.
  • Visual Studio 11 includes LocalDb database server rather than SQLEXPRESS. During installation, the EntityFramework NuGet package checks which database server is available. The NuGet package will then update the configuration file by setting the default database server that Code First uses when creating a connection by convention. If SQLEXPRESS is running, it will be used. If SQLEXPRESS is not available then LocalDb will be registered as the default instead. No changes are made to the configuration file if it already contains a setting for the default connection factory.

The following new features are also available in the Entity Model Designer in Visual Studio 11 Beta:

  • Multiple-diagrams per model allows you to have several diagrams that visualize subsections of your overall model.
  • Shapes on the design surface can now have coloring applied.
  • Batch import of stored procedures allows multiple stored procedures to be added to the model during model creation.

 

Getting Started

You can get EF 5 Beta 2 by installing the latest pre-release version of the EntityFramework NuGet package.

PM> Install-Package EntityFramework –Pre

 

These existing walkthroughs provide a good introduction to using the Code First, Model First & Database First workflows available in Entity Framework:

We have created walkthroughs for the new features in EF 5:

 

Compatibility

This version of the NuGet package is fully compatible with Visual Studio 2010 and Visual Studio 11 Beta and can be used for applications targeting .NET 4.0 and 4.5.

Some features are only available when writing an application that targets .NET 4.5. This includes enum support, spatial data types, table-valued functions and the performance improvements. If you are targeting .NET 4.0 you still get all the bug fixes and other minor improvements.

 

Support

We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow.

We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

 

Entity Framework Team

License.rtf

Comments

  • Anonymous
    March 22, 2012
    Excellent! How does one roll this out to all projects in a solution?

  • Anonymous
    March 22, 2012
    good  come  ...咋不出中文版博客呢....

  • Anonymous
    March 22, 2012
    come  on

  • Anonymous
    March 23, 2012
    I've just applied this, it has certainly fixed the “Sequence contains no elements bug” which we were experiencing in beta 1.   I am interested to know, having previously been on the June 2011 CTP, should I expect to see performance increases with EF 5 compared with the aforementioned CTP?  I ask, because a previous blog post talks about the Auto-Compiled LINQ Queries being in the June 2011 CTP, so are there performance improvement over and above those in EF5?

  • Anonymous
    March 23, 2012
    @Paul2zl, You will see the perf improvements if your app targets .NET 4.5. Cheers, Andrew.

  • Anonymous
    March 23, 2012
    When can we expect support for TVF in code-first?

  • Anonymous
    March 23, 2012
    @James Hancock – If you haven’t installed the package before then run the Install-Package command for each project that you want to reference EF in (There is a ‘Project’ drop down in Package Manager Console). If you have already installed it then just run the Update-Package command for any project and NuGet will update all the projects that have EF installed. @Khaled – We’ve been doing some planning for EF 6 and currently TVF/SPROC support for Code First is one of the first features we are going to implement in EF 6. We’ll publish some more info on our planning shortly.

  • Anonymous
    March 23, 2012
    Hi, could you share samples of Code First migrations in Visual Basic? Thanks, Cláudio Ralha

  • Anonymous
    March 25, 2012
    Are there any hopes to have support for SQL Server 2012 (like paging using OFFSET/FETCH) in the upcoming EF 5.0 release? (I realize that this requires support from the corresponding ADO.NET provider, it's not just EF, and that maybe it's a separate team, but still..)

  • Anonymous
    March 25, 2012
    Hey guys, I am missing the EF 5.x DbContext Generator Extension. It's not available in the online gallery!

  • Anonymous
    March 26, 2012
    I would like to see the version of Power Tools for Visual Basic

  • Anonymous
    March 26, 2012
    Note that if you have a vs11 solution with more than one project, if you install ef 5.0 beta2 into the first project in the explorer list (using the package console), then you can't install it into the other projects of that solution: the package console says it's already installed.  Instead, you have to manually reference each of the ef files.  

  • Anonymous
    March 27, 2012
    @ClaudioRalha – In this walkthrough all the code is generated for you, if your using a VB.NET project then Migrations will generate VB.NET code for you. The rest of the walkthrough steps are exactly the same. @Tudor – Not in EF 5.0 timeframe (we’re very close to RTM now), but we’ll look at these in the EF 6 release. @Uli – The extension is there but currently only available for Visual Studio 11, we’re uploading templates in the next couple of days that will also work with Visual Studio 2010. @Veranildo Veras – The next version of the Power Tools allows you to customize the code generation templates. Once we get that released it will be very easy for us (and others) to provide additional templates (including VB.NET). @techvslife – I haven’t seen this issue and have been able to install the NuGet package in multiple projects (it does give you a message saying it’s already installed in another project so it’s going to reuse the already downloaded package). Can you start up a Stack Overflow thread with some steps we can use to reproduce the issue.

  • Anonymous
    March 28, 2012
    Hey Guys, is there a reason why you don't offer an IDbContext interface? It would appreciate that for testing reasons!

  • Anonymous
    March 29, 2012
    Hi, is there any twitter account to follow the changes of the blog?

  • Anonymous
    March 29, 2012
    @Rowan Miller.  yes I get the same message, that it's already installed in the first project.  however, it does NOT install the ef package in the  second project, so you get error messages when using ef in that other project, unless you manually install ef into the second project.  (It may be that installing in one project only is by design and I'm overlooking a simple step.)  Note this is when installing ef5 (so using package console).

  • Anonymous
    March 30, 2012
    Hi, you did a great job with EF Power Tools and the only thing i'm really missing is an option to use/don't use pluralization of entities. So my question is will you implement this feature in EF Power Tools Beta 2?

  • Anonymous
    April 01, 2012
    How do I use transactionscope with this version? Its not available on reference manager.

  • Anonymous
    April 02, 2012
    The comment has been removed

  • Anonymous
    April 03, 2012
    Any plans för async api for Loading entities and saving changes now that the core ADO.NET received async support?

  • Anonymous
    April 03, 2012
    @Daniel_Svensson: yes, async support is one of the top priorities for the next version after EF 5.0.

  • Anonymous
    April 05, 2012
    I'm seeing a weird bug with EF5 b1 and 2 where in the second of two updates results in the sql to the db using the first objects command parameters.  I'm trying to reproduce it in a simpler app. If I succeed, anywhere special I should send it?  Its currently a rather complicated win8metro/portable library/POCO's/wcfservice/ef5/sql2012 string of things (I couldnt find any other beta software to shove in that stack to make it less stable).  In any event, this one looks like the db context (which is new for each wcf call) is keeping around the original command bindings and ignoring the new values im submitting.

  • Anonymous
    April 05, 2012
    @Guy_Oliver - Starting up a thread on Stack Overflow is our preferred option, that way the info is all public and searchable for anyone else that hits the same problem.

  • Anonymous
    April 09, 2012
    EF 5.0 Beta 2 breaks web api. How does one use Web API with EF 5.0 Beta 2? It worked ok with Beta 1 and the beta of Vs.net 2011 but borks now....

  • Anonymous
    April 09, 2012
    @James Hancock - Can you start up a Stack Overflow thread with details of the error you are seeing?

  • Anonymous
    April 10, 2012
    I am exploring the code first workflow. I stuck with following issues. Is any other workflow support any of them?

  1. How can we use Interface as property type in Entity? e.g. class MyData { public int Id {get;set;} public string Name {get;set;} public IDataSource {get; set;} } interface IDataSource {   string Source {get;set;} } class FileDataSource : IDataSource {   public string Source {get;set;} }
  2. I tried using abstract class instead of Interface. It works fine with saving data, but does not work with retrieving. e.g. class MyData { public int Id {get;set;} public string Name {get;set;} public DataSource {get; set;} } abstract class DataSource {   public string Source {get;set;} } class FileDataSource : DataSource {   public string FilePath {get;set;} } It storing all the data including FilePath. But it does not retrieve FilePath while retrieve the data.
  3. Can we use Dictionary with EF? Regards, Hitesh
  • Anonymous
    April 11, 2012
    @Hitesh
  1. Interfaces are currently not supported by EF.
  2. The abstract class pattern is supported, to get the data included when you query you can use the Include method (context.MyData.Include(m => m.DataSource). Alternatively you could mark the property as virtual and EF will automatically query for the data when you try to access the property.
  3. Dictionary properties are currently not supported.
  • Anonymous
    April 11, 2012
    Thanks Rowan. For 1 & 3; is any other workflow (Model First or DB First) support these?
  1. It is working fine with 'Include', but not working by marking property as 'virtual'. I tried all permutation e.g. marked FilePath property as virtual, DataSource Property, both, etc., none of them worked. I even tried setting LazyLoadingEnabled (context.Configuration.LazyLoadingEnabled) true/false, no luck. I am using VS2010 SP1, EF5 Beta2 with .Net 4.0.  I even tried with EF 4.3. Why it is not working by marking property as virtual? Is there any problem with environment or any other issue? And in case if it is due to lazy loading, then why it is not retrieving 'FilePath' when I access it first time? I experimented one more thing, I added few more properties in DataSource base class. All of them are retrieved, but derived class's (FileDataSource) property 'FilePath' didn't. What could be the reason?
  • Anonymous
    April 11, 2012
    The comment has been removed

  • Anonymous
    April 12, 2012
    @Hitesh - Can you start a Stack Overflow thread with the code for your model (classes and context) and some code that shows how you are querying? That will help us debug what is happening.

  • Anonymous
    April 15, 2012
    "EF 5 includes bug fixes to the 4.3.1 release" Where are they listed?

  • Anonymous
    April 16, 2012
    What about support for storing enums using their string values? Storing enums as ints may not be desirable (a good explanation here: stackoverflow.com/.../ways-to-save-enums-in-database). Int values are not resilient to future migrations and data can get corrupted very easily as new enum values are introduced into the system over time. Will EF 5 support storing the enum values as strings? (PS the comments on the "EF 5.0 Enums Walkthrough" are closed - would be nice to open them to design discussions)

  • Anonymous
    April 17, 2012
    The comment has been removed

  • Anonymous
    May 10, 2012
    Can someone answer me, where I can find out if HierarchyID will be suported in EF5 or not? I have found many comments on other blogs but I can not confirm this from anyone. Is there somewhere where I can find out what is planed for the EF? Thanks,

  • Anonymous
    May 11, 2012
    Will .NET4.5 Framework be shipped with EF5?

  • Anonymous
    May 11, 2012
    @Patrick Miron - Unfortunately EF5 will not have support for HierarchyID. You can view and vote on features at http://ef.mswish.net. @Tom - EF5 can be used against .NET 4 and .NET 4.5. We will not ship .NET with EF5... but most of the new features in EF5 'light up' when you use it to write an application targeting .NET 4.5.

  • Anonymous
    May 13, 2012
    Contrary to what the blog post says, enums seem to work just fine even on .NET 4.0.

  • Anonymous
    May 14, 2012
    The comment has been removed

  • Anonymous
    June 23, 2012
    Hi, If I use EF5 targeting .NET4.0, will it get any performance improvement? What about the SQL generation improvements around optimizing queries over models with table-per-type (TPT) inheritance  (mentioned in June 2011 CTP)?

  • Anonymous
    June 25, 2012
    @tk - No, you need to target .NET 4.5 to get those improvements. This is a side effect of us still having some of the original parts of EF in the .NET Framework, in future releases we'll be moving those last pieces into the NuGet package too.

  • Anonymous
    July 06, 2012
    Good!  EF update so quickly. Thank you.

  • Anonymous
    July 10, 2012
    I am using this release but still have the "Sequence contains no matching element" issue. My POCO classes have been moved to another assembly and is referenced in the context assembly. Mapping files are also located in the context assembly. Could this be the issue?

  • Anonymous
    July 13, 2012
    @Warren Parry – Splitting between assemblies like that is supported. Any chance you could send us a project that reproduces the issue? If so, use the ‘Contact’ link at the top right of the page and we can organize it over email.