I have a 4.6.1 class library with entity framework DB connections. I want to use that with .NET Core 2.0, is that possible or will I have to convert the class library to .NET Standard?
@Lars: sorry for the delayed answer. It depends on what "flavor" of Entity Framework you are currently using. Entity Framework 6 was built for .NET Framework and does not currently support .NET Standard or .NET Core. If you are already using Entity Framework Core, you should be able to move your code between .NET Framework and .NET Core without changes.
If you are currently using Entity Framework 6 (or previous versions) but need to run on .NET Core, then moving your application to Entity Framework Core is worth considering, but beware that doing that is a porting exercise and not a simple version update.
@LeeReitz: You will still start getting brand new DbContext instances (as long as you don't run of memory).
There is a pooSize argument on AddDbContextPool<T>() that allows you to control how many instances will remain in the pool ready to be resolved, but it doesn't limit how many DbContext instances can be created. The default poolSize, if you don't specify it is 32.
@Atlantisbase: NuGet will be available in all SKUs of Visual Studio 11. Unfortunately I don't think there is a way to get NuGet to install in Visual C# Express 2010 or Visual Basic Express 2010, but here is a workaround:
@Edson_Ferreira: I have seen this error come up when your login credentials actually lack the necessary permissions in SQL Server.
This is often the consequence of installing SQL Express using a different user account from the one you are trying to use it. It has happened to me when I take a virtual machine image prepared by another person.
One way to confirm this is your case would be to open SQL Server Management Studio logging in with your regular use account and attempt to create a database manually, e.g.:
USE master; CREATE DATABASE delete_me_next;
If you get the same error message you are getting is code first, there is your problem.
You should be able to work around this by running Visual Studio and your Code First app as an administrator every time, but this is not very safe so I would recommend that you rather grant the required permissions to your login use in SQL Server permanently.
There might be an easier way but you should be able to do the later this way:
Starting SQL Server Management Studio as an administrator (you should now be able to create and drop databases)
Expand the Root/Security/Logins node on the Object Explorer
If there is an entry for your Windows account right click and open properties, otherwise create a new login for your Windows user account.
Under Server Roles make sure there is a checkmark on a server role that has permissions to create databases, e.g. dbcreator or sysadmin.
If this is not the reason CREATE DATABASE is failing, another possibility is that the local account under which the SQL Server service is running doesn't have the necessary file system permissions to create files in the default location for new databases (i.e. under the ...\MSSQL\DATA directory).
@Lee Colins: Tugberk is right. DbContext and MVC both work with the "buddy class" pattern explained here: https://msdn.microsoft.com/en-us/library/ee256141.aspx (look for the MetadataType attribute in the article). This is your best option to specify data annotations for validtion if you are using code generation to get your entities. I would also add that DbContext validation checks string lenght and nullability constrainst specified in your EDM model without the need to have data annotations in your C# or VB classes.