Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In Azure, I have a database called Sismos, this was targeted by my WCF service, I created a copy of this database like this on Azure:

CREATE DATABASE sismos_cfe AS COPY OF Sismos;

This was because the initial database was only a for testing and will be used for other purposes and this new one will handle all the work for this WCF servive.

In my WCF service, I changed the following line in my Web.config file:

<connectionStrings>
    <add name="Model1Container" connectionString="metadata=res://*/Sismos.csdl|res://*/Sismos.ssdl|res://*/Sismos.msl;
    provider=System.Data.SqlClient;provider connection string=&quot;data source=*******.database.windows.net;
    initial catalog=Sismos;persist security info=True;user id=*******;password=*****;
    multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

With this:

<connectionStrings>
    <add name="Model1Container" connectionString="metadata=res://*/Sismos.csdl|res://*/Sismos.ssdl|res://*/Sismos.msl;
    provider=System.Data.SqlClient;provider connection string=&quot;data source=******.database.windows.net;
    initial catalog=sismos_cfe;persist security info=True;user id=*****;password=******;
    multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

And this line in my app.cofig file:

<connectionStrings>
    <add name="Model1Container" connectionString="metadata=res://*/Sismos.csdl|res://*/Sismos.ssdl|res://*/Sismos.msl;
    provider=System.Data.SqlClient;provider connection string=&quot;data source=******.database.windows.net;
    initial catalog=Sismos;persist security info=True;user id=****;password=*****;
    multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

With this:

<connectionStrings>
    <add name="Model1Container" connectionString="metadata=res://*/Sismos.csdl|res://*/Sismos.ssdl|res://*/Sismos.msl;provider=System.Data.SqlClient;
    provider connection string=&quot;data source=******.database.windows.net;
    initial catalog=sismos_cfe;persist security info=True;user id=****;password=*****;
    multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

As you can see, I only replaced the value of the initial catalog property, instead of pointing to Sismos, it now should point to cfe_sismos.

The problem I'm having is that when I try to access one of my endpoints that deals with deleting an entry in the database, no change is made in the database at all. With operations of selecting entries or editing/inserting an entry there's no problem. With the initial catalog property value eing Sismos there's no problem with any of the endpoints, in theory any database access should be directed to the cfe_sismos database.

Was it not enough with me replacing the initial catalog property value? Any help will be appreciated.

EDIT

I just noticed that there's also problems and odd behaviour when editing an entry, for example, if I have an entry in my table Users and I edit the Last_Name, the change won't be reflected when I check my database on Azure, but if I call the endpoint that returns the users, the change will be present, I gave some time to see if there was some kind of delay preventing from showing the newest values in Azure, but it didn't show any changes. How can I be making changes in the database without those changes being shown in the actual database? If I try to insert a new entry into a table, the entry will be shown with no problem.

So in summary, through my endpoints in my WCF service, if I insert something it will be shown in azure, if I edit something it won't be shown in Azure(but the change will be available when calling the respective endpoint) and if I want to delete something it won't be shown in Azure nor the change will be reflected when calling the endpoint.

If the database in Azure is not receiving any changes, then where am I getting all of the information? It's like a cached database exists somewhere, I'm really confused at the reason for this is happening.

I'm really confused at this odd behaviour, so I hope someone can help me. Thanks in advance.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

I finally found the reason for the odd behaviour. The thing is that Entity Framework can't work with objects that are copied from another obtained from the Context object generated by Entity Framework.

What I was doing was storing the data from my entities into static Lists to avoid as many connections to the database as possible, only making connections when an insert, update or delete operations were needed. But when I tried to get an object from those lists and use it to update or delete on the database, since it wasn't obtained from the context, then the operations is invalid. This is why only insert operations were working properly, since those are new objects and can interact with no problem with the context.

So in the end I changed the logic for the update and delete operations on my DAO classes, so instead of doing this:

Clusters cluster = (from c in DatabaseInfoHolder.ListaClusters 
    where c.ClusterId == model.ClusterId select c).FirstOrDefault();

I went with this:

Clusters cluster = (from c in context.Clusters 
    where c.ClusterId == model.ClusterId select c).FirstOrDefault();

I was hoping for Entity Framework to recognize the values from the object in my static Lists, but it seems it doesn't work that way.

share|improve this answer
add comment

Are you certain your user has rights to DELETE?

share|improve this answer
 
yes, the user I'm using is an administrator –  Uriel Arvizu Jul 11 '13 at 20:28
add comment

Your config says "initial catalog=sismos_cfe" but you said "CREATE DATABASE cfe_sismos"

sismos_cfe != cfe_sismos

share|improve this answer
 
that was a misspelling on my part in the question, the database is called sismos_cfe. –  Uriel Arvizu Jul 11 '13 at 20:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.