entity-framework-5

EF5 Code First (Error cannot be inferred from the usage)

会有一股神秘感。 提交于 2020-01-17 09:25:22
问题 Ok, I have been pulling out my hair because I simply cannot make a many to many relationship. I have the following two models: public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } public string CompanyName { get; set; } public string FirstName { get; set; } public string Lastname { get; set; } public string EmailAddress { get; set; } public string PhoneNumber { get; set; } public

EF5 Code First (Error cannot be inferred from the usage)

允我心安 提交于 2020-01-17 09:25:13
问题 Ok, I have been pulling out my hair because I simply cannot make a many to many relationship. I have the following two models: public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } public string CompanyName { get; set; } public string FirstName { get; set; } public string Lastname { get; set; } public string EmailAddress { get; set; } public string PhoneNumber { get; set; } public

MVC Getting Error - CREATE DATABASE permission denied

纵饮孤独 提交于 2020-01-15 12:47:29
问题 I am using MVC first time, and I got this error when running the application. Here are my steps. Create a new MVC empty Project Install Entity framework 5.0.0 ( PM> Install-Package EntityFramework -Version 5.0.0 ) Add two classes in Model- MovieReview.cs and MovieReviewContext.cs . MovieReview Class is this And MovieReviewContext Class is this In Controllers folder I add a new Controller, named HomeController. Here is it . Then I run it on Google Chrome or on IE. And I got the error I

How do you remove old version of entity framework in GAC?

非 Y 不嫁゛ 提交于 2020-01-15 11:26:06
问题 Yesterday I posted a question about a issue related to entity framework version after installing MVC 4 on visual studio. Somehow visual studio is still pointing to the old version of the dll (4.3.1.0) eventhough I manualy set it in my reference to the new one I tried solution suggested by danielovich gacutil /u "EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" But it did not find it No Assemblies Found Matching EntityFramework, Version=4.3.1.0, Culture

Comparing performance of generated queries for Any() vs Count() in Entity Framework 5

怎甘沉沦 提交于 2020-01-14 14:24:31
问题 In my project I use Entity Framework 4.4.0.0 and I have the following dilemma. I have to check if an user is activated. My query looks like: Any() _context.Users.Any(u => u.Id == userId && u.IsActivated); The generated sql is: SELECT CASE WHEN ( EXISTS (SELECT 1 AS [C1] FROM [dbo].[Users] AS [Extent1] WHERE ( [Extent1].[Id] = @p__linq__0 ) AND ( [Extent1].[IsActivated] = 1 )) ) THEN cast(1 AS BIT) WHEN ( NOT EXISTS (SELECT 1 AS [C1] FROM [dbo].[Users] AS [Extent2] WHERE ( [Extent2].[Id] = @p_

Cannot insert the value NULL into column 'Discriminator' AspNetUsers Table

笑着哭i 提交于 2020-01-14 08:10:12
问题 After a code first migration, adding a user using the register fails with: Cannot insert the value NULL into column 'Discriminator', table 'aspnet-BSF2013-20130918101120.dbo.AspNetUsers'; column does not allow nulls. The create user code is the default code generated by the Project Template (Vs2013, MVC project with EF5) Before a successful migration, the Registration code worked, so I'm guessing that membership has been altered by EF. 来源: https://stackoverflow.com/questions/18938514/cannot

Cannot insert the value NULL into column 'Discriminator' AspNetUsers Table

房东的猫 提交于 2020-01-14 08:09:29
问题 After a code first migration, adding a user using the register fails with: Cannot insert the value NULL into column 'Discriminator', table 'aspnet-BSF2013-20130918101120.dbo.AspNetUsers'; column does not allow nulls. The create user code is the default code generated by the Project Template (Vs2013, MVC project with EF5) Before a successful migration, the Registration code worked, so I'm guessing that membership has been altered by EF. 来源: https://stackoverflow.com/questions/18938514/cannot

Entity Framework 5 - Migrations and creating table from entity

纵然是瞬间 提交于 2020-01-13 16:55:25
问题 I am using Entity Framework 5 RC and i have some code that require a specific table on the database. The entity is already created using Code-First. a) Is there a way to tell EF to create the table if its not already created in the database ? If yes.. how ? b) Also.. if the table already exist, can it handle entity changes such adding properties to the entity.. will it get reflected on the database ? (We still use the code-first approach here) Thanks! 回答1: Use code first migrations (either

Entity Framework 5 stopped running T4 templates files on save

北城余情 提交于 2020-01-13 12:08:31
问题 At work we just upgraded to Entity Framework 5. Our EDMX file now has a couple other nodes beneath it: EntityContainer.Context.tt which contains the generated DbContext object and EntityContainer.tt which contains the entities themselves. For a short period, adding an entity in EF was automatically regenerating the tt (T4 Templates) when we would save the EDMX file. Now all of a sudden we have to right-click the T4 templates and select "Run Custom Tool" to get them to regenerate the .cs files

Entity Framework 5 stopped running T4 templates files on save

亡梦爱人 提交于 2020-01-13 12:08:13
问题 At work we just upgraded to Entity Framework 5. Our EDMX file now has a couple other nodes beneath it: EntityContainer.Context.tt which contains the generated DbContext object and EntityContainer.tt which contains the entities themselves. For a short period, adding an entity in EF was automatically regenerating the tt (T4 Templates) when we would save the EDMX file. Now all of a sudden we have to right-click the T4 templates and select "Run Custom Tool" to get them to regenerate the .cs files