Jump to content



Photo
c# wcf entity framework

  • Please log in to reply
3 replies to this topic

#1 paxa

paxa

    Neowinian

  • Joined: 04-June 04
  • Location: so far away....nearly in the end of the world

Posted 08 January 2013 - 00:25

i'm having some problems with entity framework and a sql database. so my problem is this: in my database there are two tables that have the same property, they are identical in type and length but they are not related in any way. no foreign key whatsoever. as soon as i start to interact with the database entity framework spits out the famous error:

error 0019: Each property name in a type must be unique. Property name was already defined.



i'm using the code first approach and a sql server 2008 by the way.

this is one of the class representations of the tables:


[Table("bo")]
public class TbPBO
{
   [Required(AllowEmptyStrings = false, ErrorMessage = "O campo de nome nao pode ser nulo")]
	[MaxLength(55, ErrorMessage = "O campo de nome nao pode ter mais que 55 caracteres")]
	[Column("nome", TypeName = "char", Order = 4)]
	public string TbBonome { get; set; }
}

this is the other class representation of the table:
[Table("bi")]
public class TbPBi
{
	[Required(AllowEmptyStrings = false, ErrorMessage = "O campo nome nao pode ser nulo")]
	[MaxLength(55, ErrorMessage = "O campo nome nao pode ter mais que 55 caracteres")]
	[Column("nome", TypeName = "char", Order = 62)]
	public string TbBinome { get; set; }
}



any idea on how to work around this? one more thing. the database must not be changed in any way. i cannot modify it.

help would be appreciated. thanks in advance


#2 OP paxa

paxa

    Neowinian

  • Joined: 04-June 04
  • Location: so far away....nearly in the end of the world

Posted 09 January 2013 - 23:01

anyone? any ideas?

#3 vetMathachew

Mathachew

    Wise beyond my youth... that's what she said!

  • Tech Issues Solved: 1
  • Joined: 19-September 04
  • Location: Spring, TX
  • OS: Windows 7

Posted 09 January 2013 - 23:25

I haven't hit this issue before, but see if this helps: http://stackoverflow...ique-an-entityc

If not, try searching other topics on SO, it's quite resourceful.

#4 OP paxa

paxa

    Neowinian

  • Joined: 04-June 04
  • Location: so far away....nearly in the end of the world

Posted 18 January 2013 - 18:47

i've solved the problem by installing ef power tools and reverse engineer my database. it created the entities and context. i've been testing the code and it works. no more problems.
thanks for the help