none
Entity Framework not working in network RRS feed

  • Question

  • Hi!

    Building a EF (i use version 6) based on a database located on my computer i have no problem. But if i use a database located on a server (Windows Server 2008 R2 also with SQL Server 2012 Express) I get many errors like:

    Error 67 'Public Property "TableColumnName" As "ColumnType" has multiple definitions with identical signatures.

    Way to get rid of the errors is to set code generation = none, but i want to work with EF objects and dont want to create Pocos.

    Why does the error occur and how can I get rid of it using code generation?

    Greetings!

    Tuesday, May 13, 2014 2:20 PM

Answers

  • Your best bet is to delete all the files to do with the creation of the EF model which includes the .tt files etc and then add it back in to the project. It will create a DbContext with .tt files. Save the newly created files and compile.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, May 16, 2014 1:18 PM

All replies

  • It sounds like you created a EF model from the database on your system and when you went to the SQL server system and created another EF model which point to it. If this is what you did are the two databases using the same database structure, in other words are they the same database just on two different machine? If so you do not have to do that all that is needed is to change the connection string and point it to the SQL server instead of the local machine.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, May 14, 2014 3:42 AM
  • Hi!

    Thanks for your answer! I checked the connection string in my app.config but it points to the SQL server. My string looks like:

     <connectionStrings>
        <add name="northwindEntities" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MyServer\SQLEXPRESS;initial catalog=northwind;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>


    • Edited by Ruediger007 Wednesday, May 14, 2014 6:42 AM
    Wednesday, May 14, 2014 6:42 AM
  • Do you have multiple EDMX models in the application?

    If you do have multiple models are they modeling the same database but just on different systems?


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, May 14, 2014 12:48 PM
  • I have just one EDMX model (northwind) in my application and there is also only one SQL-Server instance with this database. I have a SqlServer installed on my pc as well but there is no northwind attached. What I found out is if I delete the two  .tt files I can set Code Generation to default and dont get errors anymore after recompiling but I delete the Classes in the .tt files as well (factory methods are quite useful and I dont want to miss them acutally) so this is a workaround (concerning the errors) but not a solution,.
    Thursday, May 15, 2014 10:41 AM
  • Well the only way I know you can get multiple definitions with identical signatures ruling out that the above has been verified is that you created the EDMX saved and compiled the project and then went back and changed the code generation to none. When you do this EF goes from using DbContext to ObjectContext leaving all the .tt code files and the files that were created from the templets and adds the same classes for ObjectContext giving you multiple classes and getting the error. Please verify that you have multiple classes for the tables in the database in your project.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 15, 2014 3:01 PM
  • I do the following steps:

    1. Create a new Project (WinForms) and save it.

    2. Create mx EF Model

    - The Model (Diagram) pops up I get the usual two securitywaring pop ups the i get the error messages (I havend compiled or recompled anything yet) in the error window. Looking into the Code generation options I see 'none'.

    - Under Model1.edmx i have the following files:

    model1.context.tt

    model1.designer.vb

    model1.edmx.diagram

    model1.tt

    I am very new to EF but it looks like the problem is that there is the same code in model1.context.tt(->category.vb) and the model1.designer.vb file. I have read that object-context API generates the desinger.cs files and DbContext API generates the tt Files (i hope this is correct). So it looks to me that ADO.NET generates both DbContext and ObjectContext from the beginning.


    Friday, May 16, 2014 6:16 AM
  • Your best bet is to delete all the files to do with the creation of the EF model which includes the .tt files etc and then add it back in to the project. It will create a DbContext with .tt files. Save the newly created files and compile.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, May 16, 2014 1:18 PM