4 posts in this topic

Posted

[color=#000000][font=Arial,]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:[/font][/color]
[quote]error 0019: Each property name in a type must be unique. Property name was already defined.[/quote]


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:


[CODE]
[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; }
}[/CODE]

this is the other class representation of the table:
[CODE]
[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; }
}
[/CODE]



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

Share this post


Link to post
Share on other sites

Posted

anyone? any ideas?

Share this post


Link to post
Share on other sites

Posted

I haven't hit this issue before, but see if this helps: http://stackoverflow.com/questions/2060278/c-sharp-entity-framework-the-entitycontainer-name-must-be-unique-an-entityc

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.