This is assuming that you're using Windows Credentials
This is our current setup:
- Defined two
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.
- Overrode the
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.