Today we are releasing the final version of Entity Framework Core 2.0, alongside .NET Core 2.0 and ASP.NET Core 2.0.
Entity Framework (EF) Core is the lightweight, extensible, and cross-platform version of Entity Framework, the popular Object/Relational Mapping (O/RM) framework for .NET.
Getting the bits
Prerequisites
In order to develop .NET Core 2.0 applications (including ASP.NET Core 2.0 applications that target .NET Core) you will need to download and install a version of the .NET Core 2.0 SDK that is appropriate to your platform. This is true even if you have installed Visual Studio 2017 version 15.3.
In order to use EF Core 2.0 or any other .NET Standard 2.0 library with a .NET platforms besides .NET Core 2.0 (e.g. with .NET Framework 4.6.1 or greater) you will need a version of NuGet that is aware of the .NET Standard 2.0 and its compatible frameworks. Here are a few ways you can obtain this:
- Install Visual Studio 2017 version 15.3
- If you are using Visual Studio 2015, download and upgrade NuGet client to version 3.6.0
Projects created with previous versions of Visual Studio and targeting .NET Framework may need additional modifications in order to be compatible with .NET Standard 2.0 libraries:
- Edit the project file and make sure the following entry appears in the initial property group:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> - For test projects, also make sure the following is present:
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Update: There have been several issues reported on using .NET Standard 2.0 libraries on .NET Framework projects. The problems and workarounds are summarized on this .NET Standard issue.
How to install
You can start using EF Core 2.0 today by installing an EF Core 2.0-compatible database provider NuGet package in your applications. E.g. to install the SQL Server provider from the command line in a .NET Core 2.0 application:
$ dotnet add package Microsoft.EntityFrameworkCore.SqlServer -V 2.0.0
Or from the Package Manager Console in Visual Studio 2017:
PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 2.0.0
Note that the SQL Server, SQLite, and in-memory database providers for EF Core 2.0 are already included in the ASP.NET Core 2.0 meta-package. Therefore if you are creating an ASP.NET Core 2.0 application, these steps won’t be necessary.
Check our documentation for more detailed installation and upgrade instructions as well as tutorials on using EF Core with different kinds of applications.
Update: One of the most common problem we have seen reported from customers upgrading to 2.0 is that you have to remove the [Provider].Design package (e.g. Microsoft.EntityFrameworkCore.SqlServer.Design) which has been deprecated. There are more details about this in the installation documentation page mentioned above.
What is new in this version
Here are some of the most salient new features in EF Core 2.0:
.NET Standard 2.0
EF Core now targets the new .NET Standard 2.0. The latter defines a shared surface area of over 32,000 APIs that works across .NET Framework, .NET Core, Mono, Xamarin and soon, the Universal Windows Platform. With .NET Standard 2.0, developers can reuse their code and skills on a wide range of platforms, application types and devices.
See our .NET implementation support documentation for detailed guidance on using EF Core 2.0 on each .NET implementation.
Improved LINQ translation
Queries are more efficient in EF Core 2.0 in multiple scenarios. As an example, we increased the number of patterns that can be translated to SQL, so many queries that triggered client-side evaluation in previous versions will no longer do it in 2.0.
Like query operator
You can now use EF.Functions.Like() in a LINQ query and it will be translated to LIKE in SQL or evaluated in memory if necessary. E.g. the following query:
var customers =
from c in context.Customers
where EF.Functions.Like(c.Name, "a%");
select c;
Is translated like this:
SELECT .[Id], .[Name]
FROM [Customers] AS
WHERE .[Name] LIKE N'a%';
Owned entities and Table Splitting
You can now define “owned” or “child” entities which group properties within other entities, very similar to how complex types used to work in EF6, but with the ability to contain reference navigation properties. In combination with table splitting, owned types allow these two entities to be automatically mapped to a single Customer table:
public class Customer
{
public int Id { get; set; }
public string Name {get; set;}
public PhysicalAddress Address { get; set; }
}
public class PhysicalAddress
{
public string StreetAddress { get; set; }
public Location Location { get; set; }
}
...
modelBuilder.Entity<Customer>()
.OwnsOne(c => c.Address);
Global query filters
You can now specify filters in the model that are applied automatically to all entities of a type in all queries executed on the DbContext. E.g. given this code in OnModelCreating:
modelBuilder.Entity<Post>()
.HasQueryFilter(p => !p.IsDeleted);
This query will only return posts that are not marked as deleted:
var blog = context.Blogs
.Include(b => b.Posts)
.FirstOrDefault(b => b.Id == id);
DbContext Pooling
Many ASP.NET Core applications can now obtain a performance boost by configuring the service registration of their DbContext types to use a pool of pre-created instances, avoiding the cost of creating new instance for every request:
services.AddDbContextPool<BloggingContext>(
options => options.UseSqlServer(connectionString));
String interpolation in raw SQL methods
The following SQL query using C# string interpolation syntax now gets correctly parameterized:
var city = "Redmond";
using (var context = CreateContext())
{
context.Customers.FromSql($@"
SELECT *
FROM Customers
WHERE City = {city}");
}
This will create a parameter @p0 with a value of 'Redmond' and SQL that looks like this:
SELECT *
FROM Customers
WHERE City = @p0
And more
We have added a few more features such as explicitly compiled queries, self-contained entity configurations in code first and database scalar function mapping (thanks to Paul Middleton for a great contribution!), and we have fixed lots of bugs.
Please check the overview of the new features in our documentation.
Next steps
We are already hard at work on the next version of EF Core and also finishing up EF 6.2
As always, we welcome your contributions!
Many Thanks
We would like to take the chance to reiterate our gratitude to everyone contributing to our project, in particular, to external contributors who made code submissions to EF Core in 2.0. By their GitHub aliases: @BladeWise, @ErikEJ, @fitzchak, @IvanKishchenko, @laskoviymishka, @lecaillon, @MicahZoltu, @multiarc, @NickCraver, @pmiddleton, @roji, @rpawlaszek, @searus, @tinchou, @tuespetre.

Any idea when GroupBy translation support and lazy loading will make it in? Those are the major blockers for us.
Shawn,
Both features are in the 2.1 plan, although lazy loading is a “stretch goal”, meaning that we will do our best to get to it.
I agree, it doesn’t make sense to use EF Core 2.0 without GroupBy support.
Can you please update the following page: “EF Core and EF6 Feature by Feature Comparison” https://docs.microsoft.com/en-us/ef/efcore-and-ef6/features
Marco,
Thanks for pointing this out. We haven’t in fact completed the documentation updates for 2.0. Tracking this particular issue here now: https://github.com/aspnet/EntityFramework.Docs/issues/449
The page was updated.
Still light years behind of NHibernate
@Onur why not contribute at https://github.com/aspnet/EntityFrameworkCore/issues and identity features that could be added/enhanced?
…or Microsoft could in the very beginning have taken Open Source on board like they now have with other products and added resources to the NHibernate team to refactor a product that *is* significantly ahead of EF in all aspects except .NET Core support….
Don’t mean to diss the hard work you guys have done, but it’s the wrong decision to invest so much time and effort in a competing product to the established open source leader in .NET. You should’ve (a) never started with EF and (b) cut your losses early and helped our NHibernate.
This is very true (I’m also not sure why MS couldn’t have done the same with Nancy rather than writing it’s own modular based version, ASP.NET Core). Still, we are we are.
How about async support?
How can we seed data with context pooling? Service Scope can’t resolve an instance of the context in Startup when pooling is on.
JT,
It would be great if you could create an issue with more information at https://github.com/aspnet/entityframeworkcore/issues/new. I can’t immediately think of anything that could prevent this from working, but for what it’s worth, there have been changes in ASP.NET Core 2.0 on how the service provider you get services from in Startup.Configure() is constructed, and now it is already scoped.
Does it now compile with .net native?
Peter,
We have been recently working with the .NET UWP team on testing EF Core 2.0 with the upcoming version of UWP that will support .NET Standard 2.0. The testing has shown (see https://github.com/aspnet/EntityFrameworkCore/issues/9281) that many of the issues reported with EF Core 1.x and previous versions of UWP have been addressed.
However there are still a few more (new and existing) issues that we need to sort out. Our current plan is to release a patch version of EF Core (likely 2.0.1) which should address all issues known until today.
Ok great, thank you.
I agree with shawn: group by is a must have! EF Core is useless for us at the moment without support for real group by. Grouping at the client is a no-go for real database applications (at least for the kind of applications we write – Line of Bussiness apps).
Why is it taking so long to add support for it? Please, don’t get me wrong, but I expected this feature to be at least available for 2.0.
It seems that Entity Framework Core does not get so much love / ressources. This is a pitty as many of us still write all this LOB Apps (and they should be a fairly big piece of the Azure based apps)
GroupBy translation is in the plan for 2.1. Thanks for sharing your thoughts.
Does it work with Oracle???
Until I here a yes, I am not adopting…
Oracle wants you to use Java instead.
We have started a sample in 2.1 which implements an Oracle provider for EF Core. It has limitations and won’t ship as a product, but it will help bootstrap other efforts as well as help us make sure our provider API is adequate in all areas.
We are of course talking to Oracle about this, but if you are an Oracle customer I would like to encourage you to ask them for .NET Standard 2 and EF Core 2 support.
Hi Deigo, I hate to say this 🙂 but every time I want to share EF Core related news to my community on Facebook, the wall post picture is always showing your photo unlike other .NET Core 2.0 related news. lol…
https://www.facebook.com/groups/sg.netdev/permalink/1942388136041990/
I’m fine with this, however, is EF Core has some kind of logo or some illustration as its product identity?
Riza,
Thanks for the feedback 🙂 I haven’t thought about how Facebook decides what picture to use for an article. I will give this some consideration. In the meanwhile, is there a way you can customize it? If I could, i would just use the purple and white .NET logo.
BTW, there is a Facebook page where we post EF announcements: https://www.facebook.com/efmagicunicorns/. Perhaps if you forward from there it will have the right branding?
Lovely…! Thanks. My feedback is, if possible, EF Core can also use .NET logo, yes the purple and white color.
So much negativity in comments…
It’s a good update over 1.1.
Keep up the good work
Thanks do0om. Glad you like it. This sort of feedback is welcome too 🙂
I’m receiving the following error when attempting to upgrade from version 1.1.2 (Microsoft.EntityFrameworkCore.SqlServer). Is .NET Framework 4.7 not supported?
Could not install package ‘Microsoft.EntityFrameworkCore.SqlServer 2.0.0’. You are trying to install this package into a project that targets ‘.NETFramework,Version=v4.7’, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I tried .NET Framework 4.6.2. Same thing…
I think this was because I hadn’t installed the Visual Studio 15.3 update. Now, Visual Studio keeps throwing a fatal error and exiting on me. I tried repairing the installation, but, it didn’t fix it. Now I’m trying a full reinstall. Not even sure how to downgrade to 15.2 if I wanted to.
Sorry to hear you are having trouble with the Visual Studio setup. I will try to find someone that may help you.
In the meanwhile, I vaguely remember that the setup directory contains some programs (batch file or executable) that you can use to cleanup your machine from Visual Studio installations.
Also, a possible explanation for the failures you posted: in general, when new version of a target Framework such as .NET Standard are released, we need to release updates to NuGet that are aware of the compatibility between the new target framework and existing framework. This new version of NuGet client is included in 15.3 and I believe downloadable updates will be available for previous versions.
I tried uninstalling 15.3, then reinstalling. That didn’t work. I also tried using System Restore, to revert to a snapshot that I had from about a week ago. When I did that, Visual Studio displayed a white window with nothing in it. I think it was trying to display the window that prompts you for what theme you want on the first time though. I couldn’t get past that screen. So, I undid the system restore. I uninstalled 15.3 and installed 15.0 from MSDN. It looked like it worked. 15.3 was bombing out even for newly created console app projects. I tried upgrading from 15.0 to 15.3. Now it is bombing out again. I want to go back to 15.2, but, don’t know how. I have been using .NET Framework 4.7. So, I can’t go back to 15.0 unless I downgrade to an older version of the .NET Framework as well. Is there an installer for 15.2 somewhere? These updates and the whole concept of “software as a service” where you have no control over what version you are running is quite problematic.
Hi Jon,
We would like to first help you get pass the fatal error on VS 15.3 first before rolling back to 15.2.
You mentioned that VS 15.3 crashed when you created a new Console Project, were you able to launch VS and sign in without a crash? If so, would you please follow the instructions from https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio-2017- especially “Provide a trace and heap dump” section – and report the crash? We will investigate the issue and if a fix is not available we will try to help you roll back to 15.2.
Thanks very much.
Thanks Huy. I’m able to sign in. Once I open or create a project, Visual Studio crashes after a few seconds. Judging by the stack trace, it looks like VS is scanning the project and something fails. I just submitted a bug report following the instructions and did a recording. However, at the end of the submit it said something about needing a running version of Visual Studio. It said that I would receive a confirmation email which I haven’t received. So, I don’t know if something failed in submitting the bug report. I don’t see it in the list if I search for it in user feedback.
I found out what the problem was. There was a Newtonsoft Json assembly installed in the GAC. It was overriding what VS needed. I found the app that installed the DLL in the GAC and uinstalled it. That fixed the problem. Thanks to Jared from Microsoft and a few others who helped me with this. I still think Microsoft should provide installers for previous updates such as for 15.2, but, greatly appreciate Microsoft’s help getting me backup and running again.
Jon, would you mind telling us what was the app that caused the issue? We would like to try to reproduce the problem if possible to see if it is something we can avoid on our end.
Thank you.
@Radames Yes, it is MarcEdit. Available at http://marcedit.reeset.net/. It’s a small program that is easy to install and uninstall. It should be pretty easy to test. I was able to confirm that that was the program that was causing the problem by uninstalling/installing it and using gacutil to see if it installed Newtonsoft Json in the GAC. I was thinking of asking them to not install DLLs in the GAC. I’m not sure why they would do that.
TPT and complex types is what stops me from going EF Core.
Shimmy,
Owned types in EF Core 2.0 support a superset of the scenarios supported by complex types in previous versions of EF.
TPT is still in the backlog. Specific feedback on why you can’t use the alternatives (e.g. TPH or composition) can help us prioritize it over other features in a future release.
Please upvote https://github.com/aspnet/EntityFrameworkCore/issues/2266 and feel free to add a comment there if you have any new data to add.
Hi,
Nice that you are releasing in line with ASP.NET Core and .NET Core.
But in your roadmap there is items related to Visual Studio Wizard, Upgrade Model from Database
Can you please, share information when are these supposed to be available? Lazy loading, group by?
Thanks.
AGyonov, we are still in the process of updating the roadmap with the 2.1 plans. In the meanwhile the query https://github.com/aspnet/EntityFrameworkCore/issues?q=is%3Aopen+is%3Aissue+milestone%3A2.1.0+label%3Atype-enhancement can give you a good idea of what we are working on.
You can check the status of
https://github.com/aspnet/EntityFrameworkCore/issues/9418 to know when the roadmap is updated.
Probably a dumb question, but when I try to install EFCore 2 on a full .NET project I get.
Could not install package ‘Microsoft.EntityFrameworkCore.SqlServer 2.0.0’. You are trying to install this package into a project that targets ‘.NETFramework,Version=v4.6.1’
what am I missing?
I think it’s because you need to upgrade to VS 15.3. However, be warned, 15.3 rendered my VS unusable. And there is no way to get back to 15.2.
So are you saying you can’t actually install the nuget packages in Visual Studio 2015? And that NuGet as a dependency manager doesn’t actually manage dependencies?
At any rate, I get the same issue, “Could not install package ‘Microsoft.EntityFrameworkCore.SqlServer 2.0.0’. You are trying to install this package into a project that targets ‘.NETFramework,Version=v4.6.1’” and neither of the workaround posted at https://stackoverflow.com/questions/44394243/entity-framework-core-2-0-on-net-4-6-1 work for me.
Fiddling a bit, I eventually (not sure how) got a slightly different error message: “To reference a library that targets .NET Standard 1.5 or higher, you need to install the .NET Standard Build Support extension for the .NET Framework from https://aka.ms/netstandard-build-support-netfx”
Of course, that url only take you to a completely unrelated advertisement for a Surface…
For best experience use Visual Studio 2017 15.3 or Visual Studio Code https://www.visualstudio.com/downloads/
If you are having issues with the 2017 installation you can run C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe
Usage: InstallCleanup.exe
mode should be one of the following:
-i | -instance: cleanup instance data (default)
-c | -cache: cleanup cache data
-f | -full: cleanup all installed assets
I upgraded to 15.3. After resolving an unrelated problem, I was able to upgraded from EFC 1.1.2 to 2.0. However, now I’m running into a versioning error with ValueTuple. I don’t know off hand why the VS update is needed, just that it seems to have cure the problem I was originally running into.
Yes this is still a problem, I experimented a little bit today to try if I could get rid of the hard coded assembly references. In my code I however still need to add one for System.ValueTuple (see below) otherwise I get an exception. If I interprete the warnings I see corrrectly the same problem will also occur for these other System libraries if you use application uses one of them runtime (I don’t)
‘SYSTEM.DATA.COMMON’, ‘SYSTEM.IO.COMPRESSION.FILESYSTEM’, ‘SYSTEM.XML.XPATH.XDOCUMENT’, ‘SYSTEM.NET.SOCKETS’, ‘SYSTEM.RUNTIME.SERIALIZATION.XML’, ‘SYSTEM.THREADING.OVERLAPPED’, ‘SYSTEM.DIAGNOSTICS.STACKTRACE’, ‘SYSTEM.GLOBALIZATION.EXTENSIONS’, ‘SYSTEM.SECURITY.CRYPTOGRAPHY.ALGORITHMS’, ‘SYSTEM.RUNTIME.INTEROPSERVICES.RUNTIMEINFORMATION’, ‘SYSTEM.IO.COMPRESSION’, ‘SYSTEM.DIAGNOSTICS.TRACING’, ‘SYSTEM.RUNTIME.SERIALIZATION.PRIMITIVES’, ‘SYSTEM.SECURITY.SECURESTRING’, ‘SYSTEM.NET.HTTP’.
@mwdavidMsConnect, for Visual Studio 2015, there is a NuGet client update that is needed to work with .NET Standard 2.0 libraries such as EF Core 2.0:
It was announced yesterday at https://blog.nuget.org/20170815/Whats-nu-in-NuGet-with-VS2017-15-3.html. You can look for it as “VS 2015 VSIX v3.6.0” at https://www.nuget.org/downloads.
Hope this helps,
Diego
I need lazy load, when will it launch?
John, we have added lazy loading as a “stretch goal” to our 2.1 release. That means we will do our best to complete it or at least make good progress on it in the 2.1 timeframe.
Table per type has been an open issue since before the 1.0 release, any update as to when it will be supported? Table per hierarchy really seems like an anti-pattern given that it forces the parent class to be aware of all potential children. Seems like EF Core is limited to relatively simple applications and data models until it can handle that and Group by.
Alex, if you haven’t already, make sure you upvote https://github.com/aspnet/EntityFrameworkCore/issues/2266 https://github.com/aspnet/EntityFrameworkCore/issues/2341 and explain your point of view there, in particular why you say that parent classes need to be aware of all potential children with TPH (I would like to understand what you mean).
GroupBy translation is scheduled for 2.1. We understand that TPT is important for many customers and more concrete feedback about why they can’t use TPH or composition can help use prioritize TPT over other important features in a future release.
Has anyone had a problem with the ValueTuple assembly? I’m receiving the following runtime error in an ASP.NET Web Forms app using .NET Framework 4.7.
Could not load file or assembly ‘System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I thought maybe I would need to add a mapping such as the following to my Web.config, but, it isn’t helping.
I vaguely remember something about how ValueTuple was going to be bundled with the Framework or something? I’m wondering if there is something special I’m missing that I need to do with that.
Hi Jon,
could you try following the recommendations from this comment?
https://github.com/ErikEJ/EntityFramework.SqlServerCompact/issues/463#issuecomment-314188903
You would need to get back to the state of the project before the upgrade, then edit the project file as indicated in that comment, and finally, upgrade to EF Core 2.0 again.
This will automatically generate some binding redirects that are required, including one for ValueTuple.
Please confirm if this helps.
FYI, I have updated the blog post with some additional “prerequisites”. Let me know if this helps.
Thanks. I reverted the NuGet update changes back using Git. Then, I added the AutoGenerateBindingRedirects and GenerateBindingRedirectsOutputType to the top of what appears to be the main PropertyGroup for my ASP.NET Web Forms application.
true
true
Debug
AnyCPU
2.0
{7CF1B86D-1DB7-4756-90A2-BC603B50BDD7}
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Library
Properties
MarcWebApplication
MarcWebApplication
v4.7
true
44358
disabled
enabled
Then I upgraded again using NuGet. It didn’t add a binding redirect for ValueTuple in the Web.config. I’m still receiving the same versioning error.
The way I have things setup. I have a library, a web app, and a console app. I added both settings to the library as well. I don’t see a ValueTuple mapping in there either. I didn’t add the second setting to the console application. The other setting was already in there and set to true.
It looks like EF Core 2 works in the console app. I did a quick test and I’m able to do a simple query. I don’t receive the versioning error there, but, do in the web app.
In all three of the projects, if I look at the references in Visual Studio, there are a lot of references that have a yellow warning triangle next to them.
I just tried creating a brand new .NET Framework 4.7 console application and adding EFC 2 to the project. The result is yellow warning triangles in the references list and it won’t bring the libraries up in the object browser. So, it appears that it’s just broken, and doesn’t have to do with existing projects being brought forward. It is broken for brand new projects as well. A .NET Core console application seems to look all right.
Thanks Jon for reporting this, and for helping diagnose the issue you were hitting previously.
At this point, I think the best would be to either start an issue in https://github.com/aspnet/entityframeworkcore/issues/new or using the VS feedback button, so that we can have more eyes on it. If you go with github, please describe again there what you have installed (e.g. Vsual Studio, Windows, .NET versions).
I have the same issue when “update-database” after updating my .NET 4.6.1 class library proj
When will you add CreateStoredProcedure support?
Williams, could you please check if the feature you have in mind is already in https://github.com/aspnet/entityframeworkcore/issues/? If it is please upvote it, otherwise please create a new issue. It is not immediately obvious to me whether you are referring only to having migration APIs to create stored procedures or whether you want support for stored procedure mapping, like described in https://github.com/aspnet/EntityFrameworkCore/issues/245.
OK Thanks. Could you please tell when will Entity Framework 6.2 stable version release? How long it takes?
Williams, We don’t have a date yet for 6.2. Well try to get a plan together soon.
This is a great release and shows the commitment that Microsoft has made to open source and providing great solutions. Keep it up! I suspect adoption will increase massively with lazy loading.
Thanks Ethan!
Thanks for the updates! Will we be waiting until v3.0 until we get an EDMX designer and/or be able to use existing databases without having to reverse engineer a model? That is what is holding my company back from adopting Core, as it goes against how our development model is setup. Thanks in advance.
Nick, if you are asking specifically for EDMX support, that is not something our team is planning to do. A designer is a different matter.
Also, what is your expectation on being able to use an existing databases without reverse engineering?
I agree with Nick. Our consulting company is structured around working with existing databases , modelling entity classes thereafter. Database design is a different skill set then creating application classes and domain modelling. There has to be a tighter relationship in the framework linking the two, EF core is too restrictive presently with domain first only and worse no visual component.
A visual class designer that can create relational entities from an existing database, among other things, is really needed.
Nimesh
+1, absolutely need a way to do “database first” design before we can shift to .NET Core.
I didn’t see any documentation on support for SQL Triggers and Stored Procedures… I ran into this issue recently and was curious if I could redo my app in 2.0… I had to add some serious code to do what SQL server can do natively…
What are you looking for with SQL Triggers? I was under the impression that those were always invisible to the client.
I would be interested in more details here. EF Core does not understand about triggers and stored procedures (yet) but it shouldn’t get in the way of you doing whatever you want with SQL natively. By the way, EF Core’s SaveChanges implementation for SQL Server is compatible with generating values using triggers.
How about custom scaffolding?? Everything changed, and there is not a single word about it. I’m getting tired of .Net, everything is a mess after each update.
Ken, are you talking about ASP.NET Core scaffolding or EF Core’s DbContext scaffolding? For the latter, we only had some bugs fixed and some implementation refactoring. It is important that if anything isn’t working as expected we get more details.
Diego, when trying to do a scaffolding with the SqlServer provider, I’m getting a nullreferenceexception if I rev Microsoft.EntityFrameworkCore.Design to 2.0.0. I suspect part of the issue is that Microsoft.EntityFrameworkCore.SqlServer.Design doesn’t appear to have been reved to 2.0.0 since the latest available version on Nuget is still 2.0.0-preview1-final. If I leave all of the references back at preview1-final, scaffolding is working. I was going to check GitHub to see if there are any open issues here. If not, I’ll add it.
Figured out my issue with scaffold. Evidently the [Provider].Design reference is no longer necessary. It may be good to include this info in the release post.
Thanks Jim, you are totally right. The notice on the deprecated provider design package is in the documentation page at https://docs.microsoft.com/en-us/ef/core/get-started/install/index but I missed including this information here. I will check to make sure all important details are covered in both.
Well!
String interpolation in raw SQL methods opens up the possibility of SQL injection in several cases outlined in this discussion
https://twitter.com/Nick_Craver/status/899629701836283904
Andreas, allow me to correct that statement: the EF Core feature doesn’t open up any new possibility of SQL injection in any new cases. It just does not eliminate the possibility of SQL injection with string interpolation unless it is used correctly. Please read the discussion carefully.
Good job on the IterpolatedString implementation to parameterize the values. Makes the syntax much cleaner and avoids the Sql Injection issues.
How long do you think EF Core and EF6 will live side by side? We have applications based on EF6, and I keep wondering when will Microsoft pull the plug on EF6, because I find it difficult to imagine you will develop two competing ORMs for long.
We don’t have plans to “pull the plug” on EF6 any time soon. It remains a fully supported Microsoft product and a very popular option among many of our customers. As an open source project it gets good attention from the community. On the other hand, we are clearly not investing on building big new features for it, and instead we will prioritize making EF Core better (including brand new features and closing the functionality gap with EF6). I hope this answers your question.
Hello, Anyone else know anything about ForSqlServerHasColumnType method?
I use it in OnModelCreating with reflection over properties and it lives in Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder class but after i update to 2.0 it couldn’t find anywhere.
You can now use HasColumnType. The removal of the “ForSqlServer” version of the method is a known change. You can find more about it under the relational metadata API section of https://docs.microsoft.com/en-us/ef/core/miscellaneous/1x-2x-upgrade#breaking-changes.
I love all the features of Entity Framework, i would use it in all my prodifficultjects but i can’t because it isn’t performative. Why ?
Instead i use Dapper but It’s difficult because doesn’t map the field as i want, just like it’s written in the Model Class.
Could you make Entity better (faster) ? It would be perfect with combined with many feature that It has.
Ricardo,
In order for us to focus on improving the performance on areas where our customers actually need it, we need actionable feedback from our customers.
Our own testing shows that EF Core performance is currently in good shape in most scenarios, although we do have a few issues tracking performance problems we know about, and in general there are always more opportunities to improve.
It would be really great if you could create issues at https://github.com/aspnet/EntityFrameworkCore/issues/new with much more information about specific performance issues you have ran into.
Other than that, I encourage you to use EF Core in combination with Dapper whenever the latter offers you what you need.
Will be any support for OData in EF core 2 ?
Prakash,
As a library, EF Core plays a role in the persistence of objects and implements LINQ for querying them. It doesn’t do anything to expose OData services but it doesn’t get in the way either.
My recommendation at this point would be to check for available OData libraries for the .NET implementation you are using and for the version of OData you want to use. The list at http://www.odata.org/libraries/ should be a good starting point. I am aware that they OData team is working on supporting .NET Standard and .NET Core support on the upcoming 7.0 release. You should be able to get more information about this at the project’s GitHub repo over at https://github.com/OData/odata.net.
I have a WPF application with a separate assembly for a repository/unit of work that uses EF. I tried a few ways to install EF Core 2.0 in the repository assembly but everything failed. When I install the packages and run the scaffold command in the UI assembly, then it works. But now the repository assembly doesn’t reference Microsoft.EntityFrameworkCore (which is placed in the packages folder underneath the UI project), and the generated DbContext class is in the UI assembly. This will cause a circular reference when the repository assembly tries to use it. What’s going on?
Hello Scott,
I don’t see enough details in your post to guess what could be going on, in particular I don’t know if the failure to install the packages is showing any errors, but here is a pointers that might help:
– Known issues with using .NET Standard 2.0 libraries (such as EF Core 2.0) in .NET Framework-based projects: https://github.com/dotnet/standard/issues/481
In particular, look at the explanation of PackageReference’s.
If this doesn’t helps, please create an issue with more details in https://github.com/aspnet/entityframeworkcore/issues/new.
Thanks Diego. I just posted this issue with more details. Please advise.
https://github.com/aspnet/EntityFrameworkCore/issues/9715
Are many-to-many relationship mappings part of this release? That was one of the main features that was missing in previous versions of EF Core.
Many-to-many without an intermediate entity is not part of this release. It is still in our backlog and is something we would like to address in one of the next few releases.
Is there any way to use NoSQL databases like MongoDB with this?
I have seen a project started in GitHub to create a MongoDB provider. I haven’t tried it yet.
We are staring the work on a Cosmos DB provider.
I’m using database first. I have a partial class that adds a property to one of the generated entities. This worked in EF6, but with EF Core I’m hitting System.Data.SqlClient.SqlException: Invalid column
when I try to construct a list of the entities that are read from the db.
Any thoughts what I might be doing wrong?
Scott, I will assume that given you are using “database first”, the property added in the partial class is not supposed to be mapped on the database.
In EF6 when you do “database first”, the mapping is defined in separate XML files so if the property is not mentioned in the XML files it won’t be mapped.
In EF Core “database first” is implemented by reverse engineering the database schema into a “code first” model, hence all the same “code first” machinery that infers column mapping from reflecting on the classes will be performed. If you need the property not to be mapped you will have to opt out explicitly, either using the [NotMapped] attribute or the Ignore() API.
Hope this helps.
Did you remove the dotnet ef command in EF Core 2.0?
I keep getting a No executable found matching command “dotnet-ef” error message.
That’s nice
Very helpful and Great information,
I appreciate advise especially coming from a professional.
Thanks again and keep up the great work!
Hi Everyone. I have a question. I am transferring my code from .net to core and I ran into a big problem
this code is not compiling. can somebody help me?
How do I transfer Mapping code from Entity Framework to Entity Worker Core?
The original code is:
modelBuilder.Entity().Map(x => x.Requires(“Field1”).HasValue(“Value1”));
It doesn’t compile and I can’t see to find the equivalent code.
Thank you
Hi Everyone. I have a question. I am transferring my code from .net to core and I ran into a big problem
this code is not compiling. can somebody help me?
How do I transfer Mapping code from Entity Framework to Entity Worker Core?
The original code is:
modelBuilder.Entity<OriginalClass>().Map<OtherClass>(x => x.Requires(“Field1”).HasValue(“Value1”));
It doesn’t compile and I can’t see to find the equivalent code.
Thank you
I have found the answer here
https://docs.microsoft.com/en-us/ef/core/modeling/relational/inheritance
My code for core will be something like this
modelBuilder.Entity<OriginalClass>()
.HasDiscriminator<string>(“Field1”)
.HasValue<OtherClass>(“Value1”)
.HasValue<OtherClass2>(“Value2”);
I hope. it works for someone in need.
Hello everybody…
How can i configure the complex types properties with the fluent api?
Armin, the documentation for owned entities (which are similar to complex types) is at https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities. Let me know if this doesn’t answer what you were looking for.