entity-framework-5

NuGet Package Manager Console Default Project dropdown is empty

偶尔善良 提交于 2019-12-22 01:33:07
问题 I recently upgraded to Visual Studio 2012 RTM Ultimate from MSDN. I'm using EF Code First Migrations to build my database in my app, and I recently added a new entity and want to scaffold the migration for it. To do this, you need to open the Package Manage Console window in VS, and type add-migration "some name here" . This will scaffold any changes to your database since the last time it was updated. The Problem This issue did not occur on VS 2012 RC The problem I'm encountering is the

How do I adapt the Entity Framework POCO T4 template to create classes in a separate project?

扶醉桌前 提交于 2019-12-21 20:25:24
问题 I like to to keep my code first - or T4 generated - POCOs in a project separated from the DbContext. This helps me ensure my entity classes aren't coupled to any one data access service. When I create a new DB first EDMX model, the wizard generates a T4 template to generate all the POCOs in the same project as the DbContext. How can I modify this template to add classes to a separate project? On closer inspection, it would probably be much easier to move the DbContext to a new project, but

Two One-to-Many relationships in the same table

橙三吉。 提交于 2019-12-21 20:18:49
问题 I have a table called SystemAccount , which (up until recently) had a MasterAccountID on it that would point to its parent account (obviously an int? ). My client has now told me that there may be sometimes where an account can have 2 parent accounts (none ever have more than that). I've been trying to make the adjustment in my SystemAccount class, but it's not generating the relationship that I want. Here's part of the class code: [ForeignKey("MasterAccount")] public int? MasterAccountID {

Enum as Key in entity framework 5 throwing error on many to many joins

廉价感情. 提交于 2019-12-21 06:48:53
问题 OK, this is a bit lengthy / obscure, but I'm getting an odd error in specific situation where I use an Enum as a table Key and attempt to query against the table while including more than one many-to-many related entities. The error, from the example code below is: The type of the key field 'DietIs' is expected to be 'MvcApplication8.Models.DietIs', but the value provided is actually of type 'System.Int32'. In a .net 4.5 web project, I have the following entity configuration : public enum

Entity Framework 5.0 EntityObject Generator not available in Visual Studio 2012 RC?

可紊 提交于 2019-12-21 06:45:34
问题 Carry over from social.msdn.microsoft.com... http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/4993d0bf-94e8-4d14-aff1-3458b4ad467f?prof=required Original Post I try to migrate a project from 2010 EF 4.3.1 (modified EntityObject generator template) up to vs 2012 rc, ef 5.0 rc and .Net 45 rc. Painfully, my old T4 template doesnt work any longer. Where can I get the correct template to migrate it to EF 5.0 ? I can compile the old project, but after starting the app I

“Cloning” EntityConnections and ObjectContexts in Entity Framework

大城市里の小女人 提交于 2019-12-21 05:03:59
问题 (This used to be a 2-part question, but since the second part is literally the important one, I decided to split this into two separate posts. See Using Serialization to copy entities between two ObjectContexts in Entity Framework for the second part. I want to create a fairly generic "cloner" of databases for my entity model. Also, I might need to support different providers and such. I'm using ObjectContext API. I am aware of this question already and the EntityConnectionStringBuilder MDSN

How to correct Polygon Ring Orientation using C# Entity Framework 5 DbGeography Spatial Data

佐手、 提交于 2019-12-21 04:39:09
问题 I'm working with the new Entity-Framework 5 using the Spatial data type DbGeography as part of my model for storing in one instance, a POINT and in another instance a POLYGON. When setting the value of my POLYGON all saves with no error however this is only the case if I draw the Polygon on the map in a clockwise order. If I draw the POLGON in an anti-clockwise direction I get an error the the sql level indicating that the data is an invalid geography type. Now after doing my own research

WebSecurity.CreateUserAndAccount propertyValues

柔情痞子 提交于 2019-12-21 04:17:16
问题 I'm writing an mvc 4 c# .net 4.5 website I want to create a new company object and register a new user that is linked to that company. My account model is: [Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string EmailAddress { get; set; } public string PhoneNumber { get; set;

Entity Framework 5 namespaces

北慕城南 提交于 2019-12-20 23:21:11
问题 I want to add Entity Framework 5 database first into a class library in Visual Studio 2012 targeting .net framework 4.5. I am confused with all the labels I need to key in: The EDMX file name when adding ADO.NET entity data model to the project. I put ‘MyEF.edmx’. When saving the connection string into the config file. I put ‘MyEntities’. After selecting some tables to include in my model, there’s a textbox to input model namespace. I put ‘MyModel’. Property ‘custom tool namespace’ of the

Entity Framework 5, switch from code first to database first?

我只是一个虾纸丫 提交于 2019-12-20 14:41:55
问题 I've already created a database using code first. It worked well. Many changes have since been made to the database outside Visual Studio. So many that any attempt at migration generates errors. So my question is, is there a way to switch a solution from code first to database first? 回答1: This should be easy, just create a new, database first model and delete your code first model. Most of your code will compile just fine if you are in the same namespace and take care of naming your context