Code first support

Nov 11, 2011 at 10:44 AM
Edited Nov 11, 2011 at 6:34 PM

Hello,

I am trying to use DAF with Code first, but there is many references to Entity class such in BaseEntityManagerProvider class. 

Do you plan to change these implementationn in order to let DAF usable with Code First ?

Regards,

Walid. 

Coordinator
Nov 11, 2011 at 5:39 PM

Yes, I'm in the process of testing things with Code First.

Nov 11, 2011 at 6:36 PM

Great news ! Thank you Marcel.

Coordinator
Nov 12, 2011 at 2:04 AM

Walid,

The latest source code now supports Code-First. Let me know if you run into any issues.

Nov 12, 2011 at 9:50 AM

Marcel,

It is Ok Code First works fine with the 9865 changeset. I thank you very much.

I am encountring anothe problem with deserialization, but and I m not sure if it is due to DAF layer or DF it self, so I'm just asking in case you had encountred the same issue. In fact, querying the server fails with this SecurityException :

The data contract type 'MyProject.MyClass' is not serializable because it is not public. Making the type public will fix this error. Alternatively, you can make it internal, and use the InternalsVisibleToAttribute attribute on your assembly in order to enable serialization of internal members - see documentation for more details. Be aware that doing so has certain security implications.

If I try to add some etities back to the server I have a similar issue...

Best  regards,

Walid.

Coordinator
Nov 12, 2011 at 5:03 PM

Walid,

I assume you are developing a Silverlight application. In Silverlight your only viable options for type visibility are Public and Internal. Silverlight prohibits non-public reflection. But before your types can be Internal, you need to make them visible to System.Core and System.Runtime.Serialization by adding the following two lines to AssemblyInfo.cs in the assemblies that contain your internal types:

[assemblyInternalsVisibleTo("System.Core, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]
[assemblyInternalsVisibleTo("System.Runtime.Serialization, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]
Nov 12, 2011 at 6:36 PM
Edited Nov 13, 2011 at 1:04 PM

You're right ! it works ! I had to add these attributes on an assembly hosting my root EntityClass !

Thank y very Marcel.