This project has moved and is read-only. For the latest updates, please go here.

Integration with SimpleMembership

Jan 16, 2014 at 5:48 PM
I recently came across TicketDesk when searching for a ticketing system that would be simple to adapt to our needs and not come with all the extra fluff that we don't need. The only unfortunate part (please excuse my inexperience with providers) is that we have implemented the use of SimpleMembership for our intranet. It seems to be working well and, as we don't want to have to log in to each intranet application individually, I was wondering if there is a simple way to integrate the existing security in TicketDesk with the database back end of SimpleMembership? Obviously some tweaks will be necessary since some of the fields you employ do not exist in SimpleMembership, but I am having a difficult time following the process TD takes to select from and write to the database.

Thanks for the work you have put into the project.
Jan 16, 2014 at 7:48 PM
Thanks for your interest Joel. I believe you should be able to convert TicketDesk to use SimpleMembership without too much effort; though I myself have never attempted it. Congratulations on standardizing your organization's security on a single provider model, though I'd be interested to know how that will work out going forward now that Microsoft has finally replaced all their old providers with the new Aspnet.Identity framework. Still though, having a standardized security model across the org is a noteworthy achievement no matter what the back-end happens to be.

TicketDesk security seems a bit more complex than you might expect because it also supports integrated AD security; but the default security implementation is based on the 2.x sql membership, role, and profile providers. I was careful to follow the default implementation as much as was possible given that system's age and limitations.

Since simplemembership is built on top of the extended membership provider infrastructure, so it shouldn't be too terribly complicated to drop it in as a replacement for sqlmembership in ticketdesk, but a good understanding of how the membership systems work is required.

TicketDesk's use of the security providers has two parts. The first is the web site itself. For the most part, the web site project is a stock use of the sql membership, profile, role and role providers. Converting this to simplemembership simply involves changing the settings in web.config to use simplememberhsip and updating the account controller and it's associated views to use simplemembership. This would be done just like any other project that you wanted to covert from sqlmembership to simplemembership. It isn't necessarily a trivial operation, but it shouldn't be too bad if you've done it with other sites before.

TicketDesk does use the sql profile provider as well, and this you would want to leave alone; even when using AD security, ticketdesk uses the sql profile provider... and if you wanted to use simplemembership you'd be better off leaving the sqlprofile provider in place as it is. Since they all ride the same underlying provider framework, it should not be a problem for the user definitions to be in simplemembership while the profiles continue using the sqlprofile provider. The stuff stored in the sql profile system has nothing to do with other applications, so incorporating this into your simplemembership implementation would only complicate things unnecessarily for both ticketdesk as well as your other applications.

The back-end of TicketDesk uses a repository pattern for talking to security systems. This abstraction was necessary to support AD and SQL membership systems in the same application. Here is where I'm less sure what you'd have to do. The odds are good that, once the front-end is converted to simplemembership, that the back-end may work just fine. The only thing unusual about how the back-end works is that the membership table has a "Comment" field, which ticketdesk uses to store the user's display name (the friendly name that gets displayed on the front-end UI). Otherwise, the back-end doesn't do anything special. However, if you do have to do something different, all you have to do is write a class that implements either SecurityRepositoryBase, or directly implements ISecurityRepository. You link the front-end to the back-end through the RuntimeSecurityMode setting in web.config. You'd make sure you set that to a custom value such as "Simple" in web.config, then make sure your ISecurityRepository was decorated with the MEF attribute like this: [ExportMetadata("SecurityMode", "Simple")] Mef will take care of hooking up the right repository from there.

If I had the time, I'd gladly prototype a simplemembership conversion of TicketDesk 2 for you... it would be an interesting experiment. Sadly though, that's time better spent on TicketDesk 3.
Marked as answer by joelpriddy on 1/23/2014 at 11:05 AM
Jan 23, 2014 at 6:34 PM
Edited Jan 23, 2014 at 6:56 PM
Thanks Stephen, I have it working now. Most of what i changed was in the web config file, however, there were some methods that were used throughout the program which were not supported by the SimpleMembershipProvider so i had to come up with alternate methods for doing the same thing.

I have a followup question: I need to add some properties to the ticket table and update the TicketDeskEntities EDM, but when I add the property, the partial class TicketPartial reclassifies itself as a System.Object instead of a System.Data.Objects.DataClasses.EntityObject . This is causing the overriden method "OnPropertyChanging" to not exist in that context. Any idea what is causing this to happen? I am looking around and it probably has something to do with the rebuild of the EDM, but I have not found the solution as of yet.

Thanks for the help.
Jan 24, 2014 at 7:45 AM
I would love to see the changes you made to get simplemembership working. Any chance you plan to fork the repository on codeplex and push a commit?

There have been lots of changes in EF since the TD 2 code was first written. It seems to compile as is, but the designers may no longer work as expected without some additional changes. I can't duplicate the behavior you are describing exactly, but can you tell me which version of visual studio you are using, and what version of entity framework you are targeting (if you've pulled in a newer ef framework?).
Jan 24, 2014 at 3:11 PM
Once I finish the project, I will look into doing that. I haven't ever put a project on CodePlex before.

I am using Visual Studio 2012 and I am targeting Entity Framework version 6. I don't recall which version of the Entity Framework you were using in TD2, but I am certain that I am targeting a newer version. I wonder if reverting back to the original version would solve my problem?
Jan 24, 2014 at 7:35 PM
I'll load up that version and run a private branch to update it to EF 6. Might take me a day or so to get to it though. I don't think simply re-targeting the stock EF framework will entirely fix the problem with the edmx designer though; it looks like the schema was updated for VS 2012 and later and I neglected to update it in source. I'll work it out though and commit an update, then let you know what I had to do to make it work right.

As for the other, forking a codeplex repository is pretty simple compared to creating a new codeplex project from scratch. It is just a source control operation, but forking doesn't create a whole new codeplex project site or anything; you won't have to manage a wiki, publish releases, and all that... the fork becomes a part of the main project site. You then just clone the fork, and work locally from that clone instead.

Of course, the forks on codeplex are public, so you probably only want to push changes that have some public value. Anything you want to keep private you'd commit on a private branch within your own local repo. You can push the private branches to another remote, such as github, which supports private repositories.... that's what I do with TD3 source; I push the public branches to the public github and codeplex repos, but I have several private forks on github where I push my private branches. That way I still have remote copies of all the code, but I don't have to put those less than stellar experiments out there for everyone to see.
Jan 25, 2014 at 7:11 AM
Ok, I've tested making changes to the edmx diagram in visual studio 2012 using the version of EF that ships with the .net framework (which is EF version 4.4). EF version 5 and 6 are seperate nuget packages, and the source code for TD2 was never updated to target those versions. The edmx schema though should be the same between version 4.4 and version 5.

What I found was that the T4 template ( in \TicketDesk.Domain\Models\DataAnnotations) is not compatible with the edmx version 3 schema (which is what VS 2012 uses). This template's job was to automatically generate partial classes for each entity in the diagram and add data annotation attributes to them. Without the T4 template, you have to hand-code these metadata classes. Since the schema for the stock TD2 version is stable, the T4 template is not particularly useful anymore.

Everything else about the edmx designer and schema appears to work fine so long as you are targeting the version of EF baked into the .Net Framwork.

What I've done is this: I have removed the T4 template, and moved it's generated metadata files directly into the project. I have commited these changes to the master branch and pushed the changes to the codeplex repo. Everything will work as before, but if you add fields to entities or add new entities you will need to hand modify/add data annotation classes yourself (which isn't difficult).
Jan 25, 2014 at 8:00 AM
For upgrading to EF 6 - First; eliminate the and include it's generated files into the project directly (see above). Then install the nuget EntityFramework package (which is EF 6.0.2 currently) into both the domain and web projects. After that, you will have to fix-up several namespaces around the application:

Most stuff from System.Data.Objects, System.Data.EntityClient, System.Data.Metadata, and System.Data.Objects.DataClasses is now located in:


You will need to install the EF 6 tools for VS2012 or VS2013

Open the edmx file in the designer, right click the design surface, and choose "add code generation item"; in the add dialog, choose to search online templates and fild the template named "EF 6.x EntityObject Generator". You can name the *.tt file whatever you want, but would be a good name for it.

Once you've added the correct code generator to the T4 code generator, the designer should remove all the code from the old code-behind file and then generate a bunch of new cs file contining EF 6 compatible model code (which will still be compatible with the data annotations metadata partials discussed above).

Once you have made these changes, everything should work as normal on EF 6 with the edmx designer.
Jan 27, 2014 at 6:09 PM
Edited Jan 27, 2014 at 6:52 PM
Ok. I followed your instructions for upgrading to EF6 and it worked great. Thanks for that detailed explanation. I did, however, have a small problem. When I tried to add a field to the Ticket class in the database (I also added the field to the TicketMeta class), i got the same error as before in the TicketPartial class:

'TicketDesk.Domain.Models.Ticket.OnPropertyChanging(string)': no suitable method found to override
'object' does not contain a definition for 'OnPropertyChanging'

I know this is due to TicketPartial being recognized as an object and not an entity object, but how is that being changed when i add a property to an entity? Very frustrating and confusing. I'm sure it's something simple. I'll let you know when I figure it out.

Anyway, thanks a lot for all of the help on this issue. It's people like you who make the open source community so awesome.

I'm not sure what I did wrong, but when I removed the old TicketDeskEntities and replaced it with your new one from GitHub, it resolved my problem. I successfully added a field and added the field to the new ticket page. It works great and I really appreciate all of the help you have given. I'm going to work on making the project more generic so I don't have the company specific stuff in it so I can add a fork to your project.
Jan 27, 2014 at 7:33 PM
Glad you got it worked out.

If you'd really prefer not to muck about with git forks and such, you can throw a copy of your code on dropbox/google drive/skydrive and send me a link to download it (just pm me through codeplex here). Just make sure it doesn't contain any company secrets or what-not.

I'll run it through beyond-compare against the original repository, and pull the changes over to a side-branch in the main repo. Of course, forking would be preferred, but I understand if you don't have time for it.