we have crm 2011 and we want to develop asp.net mvc 4 project which uses crm 2011 db. What is the best way to do this?
Also we have these questions: Can we use svcutil generated classes? Which is more suitable for such project Database first approach or code-first approach or other?
This is assuming that you're using Windows Credentials
This is our current setup:
IOrganizationService
property (instance, not static, since it's not thread safe) in a base controller class that is used by all controllers that is a lazy loaded OrganizationServiceProxy
. One is just called Service
, and is created with the default Windows Credentials of the App Pool user. The other is called UserService
and is impersonating the logged in user.Dispose
in the base controller to ensure that the OrganizationServiceProxy
is being disposed.After this initial framework is setup, it's all basic SDK calls from here. There is no issues using the srvcUtil generated classes, except that you can't store them in the session since they aren't marked as serializable (although you can store the Attributes collection).
As far as code first or database first, you'll want to create your entities in CRM first so you can generate your early bound classes and use them in the MVC site.