English 中文(简体)
EF 5.0 Enums Not Generating
原标题:

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

  1. 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?

  2. 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.

问题回答

暂无回答




相关问题
Entity Framework with MySQL connector in c#

I have been trying to get the Entity Framework to work in my web application using MySQL. It works fine on my local pc, but doesn t work when I put it on the server. Since the server is a shared ...

How Do I Create And Update A Many To Many Relationship With EF

I am using the Entity Framework with SQL Server. I have a many to many relationship between 2 tables. I have created a join table with just the primary key fields of the 2 tables. In the designer, the ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Linq to enties, insert foreign keys

I am using the ADO entity framework for the first time and am not sure of the best way of inserting db recored that contain foreign keys. this is the code that i am using, I would appreciate any ...

Entity Framework - Many to many question

I have a table called ASB and a table called PeopleInvolved. There is a junction table called PeopleInvolved_ASB which simply contains an ASBID and a PeopleInvolvedID column. The columns act as a ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

ADO.NET Entity Data Model are not precise enough

I run this code: var cos = from k in _db.klienci_do_trasy where k.klient_id == 5 select k; but the query send to database is: SELECT * FROM `klienci_do_trasy` LIMIT 0, 30 why is it for, there ...

热门标签