-1

At the moment I'm using the repository pattern in C# from this blog. The code of the project can be found here.

Now all seems to work, but I've got an Entity Data Model (.edmx) in my project that I would like to use with this code.

At the moment I've got this code:

public UnitTest1()
    {
        ObjectContextManager.InitStorage(new SimpleObjectContextStorage());
        ObjectContextManager.Init("TraceDb", new[] { "Infrastructure.Test" });

        repository = new GenericRepository();

    }

But this doesn't seem to work, note that schema namespace of the .edmx is "Trace.DAO.Entity". But also with "Infrastructure.Test" which is the namespace of the .Designer.cs of the .edmx the test wont run properly.

Ps. This is the error I get:

Failed TestMethod1 Infrastructure.Test Unable to create instance of class Infrastructure.Test.UnitTest1. Error: System.ArgumentException: No mapping class found!.

Anyone got a solution for my problem or knows how to use an .edmx with this sourcecode?

Community
  • 1
  • 1
Julian
  • 1,105
  • 2
  • 26
  • 57
  • 1
    -1 because even partial understanding of your problem demands reading very long blog post and perhaps also check source code. You should put your own effort to localize the issue or describe it in few paragraphs. This is terrible long and quite lazy from your side. – Ladislav Mrnka Aug 10 '11 at 17:23

1 Answers1

1

That code will not work with EDMX because it uses completely different approach. You will have to modify that infrastructure code to support mapping in EDMX. The infrastructure expects fluent configuration classes but that is only for code first mapping. EDMX is mapping itself.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Would it work if I generate EntityTypeConfigurations from my .edmx? – Julian Aug 10 '11 at 17:21
  • That mean replacing EDMX with fluent configuration = not using EDMX at all. I'm not sure if there is a tool for generating configurations from EDMX. – Ladislav Mrnka Aug 10 '11 at 17:29
  • But why wouldn't they use an EDMX while working with the EF? I mean it's much easier to make the whole database/entity diagram with it right? – Julian Aug 10 '11 at 17:35
  • I'm not sure what you mean by that question. Simply there are [different approaches to use EF](http://stackoverflow.com/questions/5446316/ef-4-1-code-first-vs-model-database-first/5446587#5446587) and not everybody likes designers – Ladislav Mrnka Aug 10 '11 at 17:44