entity-framework-ctp5

Autogenerate primary key (Guid) Entity Framework CTP5

百般思念 提交于 2020-01-24 21:33:27
问题 I have a following POCO class public class Account { [Key,DatabaseGenerated(DatabaseGenerationOption.Identity)] public string AccountId { set; get; } public string FirstName { set; get; } public string LastName { set; get; } public string Email { set; get; } } I get the following exception when the database gets created Identity column 'AccountId' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, and constrained to be nonnullable. 回答1: Shouldn't you

What Causes The INSERT statement conflicted with the FOREIGN KEY constraint?

非 Y 不嫁゛ 提交于 2020-01-20 03:21:32
问题 This code has worked for me before but i am not sure anymore what has been causing this error. My only guess is that when i try to create a Player, the Team Data is being sent back to Team table and its trying to duplicate but since TeamId is unique hence this error. Error The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.Players_dbo.Teams_TeamId". The conflict occurred in database "Web", table "dbo.Teams", column 'TeamId'. The statement has been terminated. Player

What Causes The INSERT statement conflicted with the FOREIGN KEY constraint?

女生的网名这么多〃 提交于 2020-01-20 03:21:04
问题 This code has worked for me before but i am not sure anymore what has been causing this error. My only guess is that when i try to create a Player, the Team Data is being sent back to Team table and its trying to duplicate but since TeamId is unique hence this error. Error The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.Players_dbo.Teams_TeamId". The conflict occurred in database "Web", table "dbo.Teams", column 'TeamId'. The statement has been terminated. Player

Entity Framework 5 - Could not load file or assembly EntityFramework, Version=5.0.0.0

两盒软妹~` 提交于 2020-01-14 07:07:13
问题 I am trying to use Entity Framework 5 for my project but I seem to be having some issue getting the assembly installed to comply. And since I installed this initially using nuget, I am not certain what I need to do to cause this to work as I expect . Any help on what I need to do to fix this problem please? * System.IO.FileNotFoundException : Could not load file or assembly EntityFramework, Version=5.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089' or one of it's dependencies The

Entity Framework 5 - Could not load file or assembly EntityFramework, Version=5.0.0.0

你说的曾经没有我的故事 提交于 2020-01-14 07:06:50
问题 I am trying to use Entity Framework 5 for my project but I seem to be having some issue getting the assembly installed to comply. And since I installed this initially using nuget, I am not certain what I need to do to cause this to work as I expect . Any help on what I need to do to fix this problem please? * System.IO.FileNotFoundException : Could not load file or assembly EntityFramework, Version=5.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089' or one of it's dependencies The

Entity Framework 5 - Could not load file or assembly EntityFramework, Version=5.0.0.0

孤者浪人 提交于 2020-01-14 07:06:05
问题 I am trying to use Entity Framework 5 for my project but I seem to be having some issue getting the assembly installed to comply. And since I installed this initially using nuget, I am not certain what I need to do to cause this to work as I expect . Any help on what I need to do to fix this problem please? * System.IO.FileNotFoundException : Could not load file or assembly EntityFramework, Version=5.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089' or one of it's dependencies The

Entity Framework 4 - TPT Inheritance in Features CTP5 (code first): rename foreign key column on inherited table

一曲冷凌霜 提交于 2020-01-14 03:38:07
问题 I'm trying to convert an xml Entity Framework model to Code First (CTP5) one. I have to model a hierarchy which fits quite well the TPT pattern. The only problem I have is that the primary key/foreign key of the "inheriting" table has a different name from the primary key of the base class. These are the relevant fields of the involved tables CREATE TABLE site.Domains ( ID INT NOT NULL PRIMARY KEY, Domain NVARCHAR(128) NOT NULL ) CREATE TABLE site.MainSites ( FKDomainID INT NOT NULL PRIMARY

EF Code First with many to many self referencing relationship

烈酒焚心 提交于 2020-01-12 04:57:30
问题 I am starting out with using the EF Code First with MVC and am a bit stumped with something. I have the following db structure (Sorry but I was not allowed to post an image unfortunately): Table - Products Table - RelatedProducts 1-Many on Products.ProductID -> RelatedProducts.ProductID 1-Many on Products.ProductID -> RelatedProducts.RelatedProductID Basically I have a product that can have a series of products that are related to it. These are kept in the RelatedProducts table with the

Code first - how can I save an ICollection when I'm not setting the parent object to EntityState.Modified?

╄→尐↘猪︶ㄣ 提交于 2020-01-01 06:16:27
问题 If I have the below class: public class Foo() { public int PropertyIWantUpdated {get; set;} public int PropertyIDontWantUpdated (get; set} public ICollection<Bar> Bars {get; set;} } When saving to my db, instead of context.Entry(thisFoo).State = EntityState.Modified; I'm using context.Entry(thisFood).Property(tf => tf.PropertyIWantUpdated).IsModified = true; how can I also save changes to Bars? 回答1: It depends what you are trying to update. First of all let me clarify one important fact - if

Entity Framework 4 - TPH Inheritance in Features CTP5 (code first) with “IS NULL” discriminator

谁说胖子不能爱 提交于 2019-12-31 04:57:05
问题 Hey guys, I'm trying to create a TPH mapping on a hierarchy where the discriminating clause is the classical "IS NOT NULL" / "IS NULL" case. Here is the example, database wise: CREATE TABLE info.EducationTypes ( ID INT NOT NULL PRIMARY KEY, Name NVARCHAR(64) NOT NULL, FKParentID INT NULL REFERENCES info.EducationTypes(ID) ) the idea is to have a class hierarchy like the following one: public abstract class EducationType { public int ID { get; set; } public string Name { get; set; } } public