c# - Make Entity Framework work with object interface and Ninject -


i have object interface defined in domain layer:

public myclass: imyclass {     public int id {get;set;} }  public interface imyclass {     int id { get; set; } } 

now iam trying use interface in context don't find way:

public dbset<imyclass> myclasses{ get; set; } 

don't work when ef try create db

i setup ninject module (binddlmodule) with

bind<imyclass>().to<myclass>(); 

and create kernel in context

ikernel _kernel = new standardkernel(new binddlmodule()); 

but don't know how use _kernel in dbset configuration type of mapped implementation

edit 1

an example illustrate mocking entities testing:

public class1 {     ...     public class1(){...}      public class2 class2property {get;}      public void setclass2 (class2 class2value)     {     //logic here     } }  public class2 { //simple class construcor , few properties } 

in test write

class1 c1 = new class1(mock.of<class2>()) 

in way class2 constructor not called , test remain atomic on class1.

edit 2

using interface not mandatory, want fake domain entities or, in other words, interface works well, ef give me problems rethink use of interface, @ point need other way unit test entities.

public virtual dbset<_kernel.get<iclass1>().gettype())> classes1{ get; set; } 

can solution if find correct sintax write it


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -