Rafael Emshoff
Rafael Emshoff

Reputation: 2729

Integrate C# SQL CLR Database Project in a MVC3 Web Application?

Background: I have already written a CLR Database Project which holds all the Business Logic for a Data-Store I'm creating. It is deployed on my SQL Server where it is referenced by various CLR StoredProcedures which take care of data imports. Now I'm working on the Web Frontend and have for this purpose started writing an MVC3 Project. Since I already have the complete Business Logic(object definitions, quality checks) I want to use the code in my MVC Application.

I figured the best way to do this is to add the BusinessLogic CLR Project to my MVC Solution and referenced it in the MVC project. That works fine, and I can use the Code. With some patience I get through most difficulties.

Issues:

1) When I want to debug the MVC solution, Visual Studio always wants to deploy the CLR Assembly. I get around this by unloading the CLR Project in the MVC solution before debugging.

2) Getting a UserDefinedType Reference from my SQLServer also seems to be a problem:

3) I deploy the same code twice on my Server, once with the SQL Assemblies, and once with my MVC frontend.

Question:

Any partial answers(i.e. glimmers of making sense) would be appreciated. I'm pretty much on my own with this.

Upvotes: 1

Views: 534

Answers (1)

James
James

Reputation: 2841

The Business Logic code could be in it's own class library, and project.

The CLR database solution then includes this BL project, and the MVC solution also includes the BL project. But the 2 solutions are separate. This would seem to solve the immediate problem - although then if you change the BL code, you then have to do 2 deployments...

It may just be that this BL layer is not living in the correct place. It would be nice if this BL lived in a service somewhere, and both the CLR procs and the MVC project accessed it in this one place.

Upvotes: 2

Related Questions