BACKGROUND
I'm using VS 2010 on a machine where I installed .Net 4.5 which I've read was an in-place install (overrode the .net 4.0 version).
I have projects still targeting 4.0 and 4.5 option is not available but was told it's ok since 4.5 was an in-place install. I then installed EntityFramework -pre via nuget and notices when I ran Upgrade-Database -Script commands, it would not generate enum properties.
I then found this. I tried doing everything from scratch again but it was still adding EntityFramework 4.4 instead of 5.0. So I manually changed all references to point to the 5.0 version to make sure I have EF 5.0 version. All compiled.
PROBLEM
When I run
Enable-Migrations -EnableAutomaticMigrations
I get "No classes deriving from DbContext found in the current project.
Edit the generated Configuration class to specify the context to enable migrations for."
So I manually made sure that my class is correct as in:
internal sealed class Configuration : DbMigrationsConfiguration<DataContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
DataContext subclasses DbContext.
When I run
Update-Database -Script
I get "No migrations configuration type was found in the assembly 'MyProject'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration)."
MyProject does have the configuration class I mentioned above and in Package Manager Console I am choosign the right dropdown for my project containing Migrations folder and this Configuration class.
QUESTION
What do I do to make sure when I install EnittyFramework via nuget that it adds the 5.0 version and not 4.4 even though I have .Net 4.5 installed?
If I can't do anything related to the question above, what can I do to make sure Upgrade-Database spit out a script?
Entity Framework 5.0 isn't out yet. There are prereleases, but you need to specifically enable prereleases in order for NuGet to display them.
However, keep in mind that EF 5.0 won't support everything in .NET 4.0 that it will in .NET 4.5. Yes, .NET 4.5 overwrites .NET 4.0, but if your project is in VS2010, it will be configured to build for .NET 4.0, not .NET 4.5. It cannot assume .NET 4.5 features, because the result needs to run on systems that don't have .NET 4.5. You're targeting .NET 4.0, after all, and enum support isn't in the EntityFramework DLL you get from NuGet, it's in the System.Data.Entity DLL that's part of the .NET runtime, so it cannot be added in .NET 4.0. You can install the Visual Studio Beta to create applications that target .NET 4.5.
In short: "was told it's ok since 4.5 was an in-place install" -- no, it's not ok for your purposes.
Related
I'm trying to run some NUnit tests written in Visual Studio on the command line using NUnit console. The tests are built using .NET 4.5.
To run them, I'm typing:
nunit3-console mytests.dll
And I keep getting a pop-up which tells me "an application on your PC needs the following Windows feature: .NET Framework 3.5 (includes .NET 2.0 and 3.0).
I've tried forcing NUnit to use 4.5 by saying
nunit3-console /framework:net-4.5 mytests.dll
But I get the same thing.
I tried installing .NET 3.5, but it can't be installed (I guess because I don't need it as I already have 4.5).
The tests run fine when run from Visual Studio using ReSharper or in the NUnit GUI...
I've created a really simple solution (tried with .NET 4 and .NET 4.5) which has a NuGet reference to NUnit 2.6.4 and one class (below):
[TestFixture]
public class Class1
{
[Test]
public void MyTest()
{
Assert.Pass();
}
}
I still get the same error.
How can I fix this?
That executable itself (nunit3-console) must have been produced by C# compiler to target .NET Framework 2.x/3.x (for the so called compatibility). Thus, when it runs on a pure .NET Framework 4.x Windows, you see the other compatibility feature by Microsoft, where it always prompts and asks to install .NET Framework 3.x (you must do that via Programs | Add/Remove Windows feature). Both of them are ridiculous as people should rarely use .NET Framework 2.x/3.x (though Microsoft will keep supporting .NET Framework 3.x as part of Windows).
To get rid of that prompt, you can enable .NET Framework 3.5 (which also gives you the bits to compile against .NET Framework 2.x/3.x). Or you modify its nunit3-console.exe.config file to use <supportedRuntime> to force .NET 4.x is used to load this executable.
I guess the NuGet version contains a proper .exe.config, while the MSI version not. You can analyze further for sure.
I'm trying to add a migration for a .net core 2.0 web app through the package manager console in visual studio 2017. I receive the error: "The EntityFramework package is not installed on project ". However, EntityFrameworkCore 2.0 is installed.
I've tried:
the enable-migrations command (although I don't believe this is necessary anymore)
the add-migration command
"Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 2.0.0" through the PMC
re-installing entityframeworkcore 2.0 through the NuGet package manager
Is there some other configuration that needs to be done somewhere else?
Since EF Core migrations work on my .Net Core 1.1 project could this issue be related to .Net Core 2.0?
Cheers!
It looks like the EF6 commands are running. You can unload them with the following command.
Remove-Module EntityFramework
The EF Core PMC commands should be available to use after installing the following package.
Install-Package Microsoft.EntityFrameworkCore.Tools
The EF tools for the command-line interface (CLI) are provided in Microsoft.EntityFrameworkCore.Tools.DotNet.
from https://learn.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations
I spent hours for this issue and finally update Visual Studio 2017 15.4.0 Preview 2.
Hope this help.
Is it possible to set the .NET Framework version for a ScriptComponentProject?
Currently it defaults to .NET 4, but I want it to be .NET 4.6.1
I've looked on the documentation page for ScriptComponentProject (https://www.varigence.com/Documentation/Samples/Biml/Script+Component+Project), but without any luck.
Ah, I found the answer! You need to set the Target Framework Version in your script project:
https://www.varigence.com/Documentation/Language/Element/AstComponentScriptProjectNode
And I think the available values are these:
Unspecified
Unspecified .NET Framework Version
NetFX20
.NET Framework 2.0
NetFX30
.NET Framework 3.0
NetFX35
.NET Framework 3.5
NetFX40
.NET Framework 4.0
NetFX45
.NET Framework 4.5
NetFX451
.NET Framework 4.5.1
NetFX452
.NET Framework 4.5.2
NetFX46
.NET Framework 4.6
NetFX461
.NET Framework 4.6.1
Which can be found here: https://www.varigence.com/Documentation/Api/Enum/ScriptProjectTargetFrameworkVersion
If you are using BIMLExpress 5.0.6xxx, you have probably faced the same issue.
I opened the generated .dtsx package and found that the TargetFrameworkVersion node placed inside of a separate PropertyGroup node. After I had moved it out to the first PropertyGroup of the same arrayElement node, then reopened my package in Visual Studio again, issue was gone! So you can write a script to move TargetFrameworkVersion node into the proper place for now.
Varigence support team told me that a public preview release is coming late next week which will include a fix for that (+also VS2017 support!).
I watched the video here: http://msdn.microsoft.com/en-US/data/jj248772, but I can't see the option to create an enum out of a property in the context menu. Also, I can't add one in the Model Browser. I have Visual studio 2012 and EF5, EntityFramework Assembly version 4.4.0.0
Entity framework assembly version should be 5.0. You are most probably targeting .NET 4.0. You need .NET 4.5 to have enum support (you will need to uninstall EF package and install it again to get EF 5.0 once you change target .NET version).
Edit: EF 6.0 should provide enums for .NET 4.0 as well.
I need to know if it is possible to start using the latest version of EF (4.3.1) with VS 2011 without having to install these CTP components as stated here.
I had these components installed but I removed them and since then I can't add a new edmx file to .net 4 targeted project; it complains about missing reference to System.Data.Entity.
Do I need to re install VS 2011?
After I removed and reinstalled Visual Studio, I still couldn't get red of the error, so I used process monitor to log what Visual Studio is doing with System.Data.Entity as a path filter, turned out that Visual Studio was reading from
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\policy.4.0.system.data.entity v4.0_0.0.0.0__b77a5c561934e089\policy.4.0.system.data.entity.config
which had binding to the
System.Data.Entity.dll v 4.2.0.0
once I cleared the file VS was worked like charm.
The CTP uninstall left this out.
Yeah should work with no issues using .net 4, however theres a list of known issues when using .net 4.5. You dont need to re-install vs to get version 4.3.1 of entity framework, simply install it from the nuget package gallery and if you are using .net 4 it all seems to just work.
Issues listed when installing EF4.3.1 on .net 4.5 include those listed below.
Known Issues with Entity Framework 4.x and .NET Framework 4.5
Entity Framework 4.1 thru 4.3 included additional data annotations in the
System.ComponentModel.DataAnnotations namespace in the EntityFramework assembly.
In .NET 4.5 these annotations were moved to be part of the .NET Framework in the
System.ComponentModel.DataAnnotations.Schema namespace of the
System.ComponentModel.DataAnnotations.dll assembly. If you are using EF 4.x and targeting
.NET 4.5 this results in two data annotations with the same name in different assemblies.
Because the annotations in the .NET Framework are in a different namespace we were not
able to use type forwarding to avoid this conflict.
It is possible to use EF 4.x on .NET 4.5 but we recommend using the latest pre-release
version of EF 5. If you are not using the affected data annotations there is no impact
on your code. If you are using the data annotations in a C# project you can use the extern
modifier to ensure your code uses the annotations from EntityFramework.dll
(http://msdn.microsoft.com/en-us/library/e59b22c5(v=VS.80).aspx). If you use the new
annotations from the System.ComponentModel.DataAnnotations.dll assembly in .NET 4.5
they will not be processed by Code First.
The affected annotations are:
Column
ComplexType
DatabaseGenerated
DatabaseGeneratedOption
ForeignKey
InverseProperty
MaxLength
MinLength
NotMapped
Table