entity-framework-5

Why I can't get Entity Framework Migration to initial state?

故事扮演 提交于 2019-12-05 04:43:02
问题 I have deleted development database, and Migrations folder from project. When running unit test with use my project development database is recreated. I don't understand why running update-database gives me PM> Update-Database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Applying code-based migrations: [201302201840012_wieleDoWielu]. Applying code-based migration: 201302201840012_wieleDoWielu. Why migration: 201302201840012_wieleDoWielu is

code first membership provider

匆匆过客 提交于 2019-12-05 04:41:51
问题 How can I integrate EF 5.0 with membership provider using code first? I have my own database schema which I want to use for registration of users etc. 回答1: You should take a look at the SimpleMembershipProvider It is very easy to use it together with EF. Update For MVC4 I would start with the blank template. you need WebSecurity.InitializeDatabaseConnection to set up the database. WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "Id", "UserName", true); It takes as

Which version of Entity Framework is used by my project?

我与影子孤独终老i 提交于 2019-12-05 04:25:09
I have a project using Entity Framework, but I am not sure which version of EF I am using. According to the Microsoft version history EF5 will install itself: If you create a new model using the Entity Framework Designer in Visual Studio 2012, the EF5 NuGet package will be installed to your project and the generated code will make use of EF5. However I did not create the EF-part of the project, but got it from version control (TFS). Now I am not sure how to determine if I have EF5. If I right-click on the References folder of the project and select Manage NuGet Packages, it show EF5 with an

Using Enums with Code First & Entity Framework 5

眉间皱痕 提交于 2019-12-05 02:41:52
Just trying to confirm an impression: it seems enums in EF5 + Code First are only supported when declared within the same namespace as the classes using them as property types. Can anyone confirm that? Couldn't find anything on the web for this... A relevant bug that was fixed earlier. 4.3 Beta 1 release notes say: Bug fix for GetDatabaseValues . In earlier releases this method would fail if your entity classes and context were in different namespaces. This issue is now fixed and the classes don’t need to be in the same namespace to use GetDatabaseValues. My guess is that GetDatabaseValues

How to solve combined one-to-one and one-to-many relationship in EF 5 Code First

巧了我就是萌 提交于 2019-12-05 02:32:31
问题 I´m using Entity Framework 5 and Code First. I have two domain entities Question and Answer for a quiz application. One question has several possible answers. A question also has one correct answer which should reference one of the possible answers. I am experiencing some issues with the combination of a one-to-many and one-to-one relationship between the to entities. See Q1 and Q2 . This is the code for the entities: public class Question { public virtual int Id { get; set; } [Required]

How to enable concurrency checking using EF 5.0 Code First?

房东的猫 提交于 2019-12-05 01:47:22
I would like to do a check-then-update in an atomic operation. I am using dbcontext to manage the transaction. I was expecting to get an exception if the record has been modified by another thread but no exception is thrown. Any help would be appreciated. Here's my output: Thread-4: Reading... Thread-5: Reading... Thread-5: Updating destination 1 Thread-4: Updating destination 1 Thread-4: SaveChanges Thread-5: SaveChanges Here's my code snippet: public static void Main(string[] args) { PopulateData(); (new Thread(UpdateDestination1)).Start(); (new Thread(UpdateDestination1)).Start(); } public

XML Fields with Entity Framework Code First

ぃ、小莉子 提交于 2019-12-05 01:18:09
问题 I'm using Entity Framework with the Code First model (pet project, and I love editing simple classes and having my schema updated automatically). I have a class like follows: [Table("Polygons")] public class Polygon { public int PolygonId { get; set; } public String Texture { get; set; } public virtual ICollection<Point> Points { get; set; } } [Table("Points")] public class Point { public int PolygonId { get; set; } public double X { get; set; } public double Y { get; set; } } It's useful to

EF 5.0 Enums Not Generating

泪湿孤枕 提交于 2019-12-05 01:00:48
问题 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

Updated to EF5 now NotMapped annotation doesn't work

China☆狼群 提交于 2019-12-05 00:26:20
I just updated the entityframework to the latest 5.0.0 version. And the NotMapped annotation doesn't work now. I tried to google for an answer to fix it but couldn't find. Anyone had the same problem when you updated the entityframework and know a solution to fix this problem? Annotation attributes in EF 5.0 with .NET 4.5 were moved to System.ComponentModel.DataAnnotations assembly and System.ComponentModel.DataAnnotations.Schema namespace. [ NotMapped ] is in System.ComponentModel.DataAnnotations.Schema . Make sure to add using System.ComponentModel.DataAnnotations.Schema; to your code. 来源:

Entity Framework 6 Error Unable to load the specified metadata resource

谁说胖子不能爱 提交于 2019-12-04 22:49:18
I'm using Entity Framework 6 and "model first" in my solution, I separated my "Data Model" classes into another project, so that I can add reference to the "Data Model" classes without exposing my "Data Model Contexts" and connections. I don't want to expose my Entity Data Model project (especially the DB Context etc) to my UI Layer. I have this: I have now successfully separated my auto generated entity classes from my data model, I tried it this works by adding an entity or a property to an entity is updated in the project Mapeo.BusinessEntity. This is my connection string from DatabaseLayer