Removing/Deleting a UserClaim in MembershipReboot with Guid keys failing - guid

I am working on a project and using MembershipReboot as the membership manager. I am using Guids for the keys instead of the ints used in the Single Tenant demo. My application can add UserClaims but I get an error when trying to remove or delete them. Some error about not being able to set a foreign key to null. There is only one foreign key in UserClaim, the ParentKey. I don't think the framework should be setting it to null anyway, it should be simply deleting the UserClaim, not modifying it. I can fix this by scanning the repository for modified UserClaims and deleting them, but this is a horrible kludge. I was just wondering if anyone else has used UserClaim and if they worked for them?
MembershipReboot Version 7.2.

Related

Entity Framework Core Scaffold - Dynamic Schema Name

I'm having an issue at the moment where, we have a database which was already created, so used ef scaffold to create a model of it - the schema the model was created against is called "xxxx-dev".
Now, this has been fine, but in preparation to go live, I created a new DB server and provisioned the database to be called "xxxx-live". Switched the connection string, and attempted a query against it, and got an error.
It seems that scaffolding has hard-coded the schema name into every table in the OnModelCreating call, for example:
modelBuilder.Entity<xxxx>(entity =>
{
...
entity.ToTable("xxxx", "xxxx-dev");
...
});
This is a bit of an issue as going forward, we might have multi-tenant sites based on the same database, and obviously the query overriding the connection string every query isn't a great experience.
Is there anyway to configure the schema name, either in the Scaffold, or at runtime? I've done a bit of searching around and can't seem to see a solution.
Thanks,

Remove asp.net MVC Entity Framework auto-generated Global Uniquie Identifiers?

I just noticed that in the database for the auto generated ids for the default authentication users table the id is not an integer, it is a very large string.b(GUID)
here is an example:
a202fc44-7319-499e-80b8-96822f5833c0
Now all of the delete methods are implemented expecting an integer id and now obviously when it passes through its id. It gives an error.
1> why is it doing the string ids in he first place?
Is there any benefits in using this for a small scale application?
2> How can I change this to just use a normal auto-incremented int?
It is using code first migrations as it is implemented when I create the project. It just creates the database on the local sql server.

How do you force the OAuth Sql Server database objects to be recreated once deleted?

Using ASP.net 4.5, I created a membership database and set up some open auth providers. In the course of adjusting the database, I deleted the open auth tables (UsersOpenAuthAccounts and UsersOpenAuthData) - I can find no script to generate these items or any other way to regenerate them.
The ASP.Net membership libraries create a system table called __MigrationHistory. When these OAuth elements are created, it creates this table (if missing) and creates a record there which acts as a flag indicating that it is not necessary to create the db items. Delete the table, and the membership libraries will recreate the elements.
You will receive an exception indicating that the __MigrationHistory table is missing - ignore this error, as it will be recreated along with the other elements.
BUT BEWARE - __MigrationHistory is a table used by Entity Framework...you may jack it up in try to fix this, so keep a backup handy.

SQL Server load balancing optimizing Hits or Optimize the query

When we developers write data access code what should we really worry about if the application should scale well and handle the load / Hits.
Given this simple problem , how would you solve it in scalable manner.
1.ProjectResource is a Class ( Encapsulating resources assigned to a Project)
2.Each resource assigned to Project is User Class
3.Each User in the Project also has ReportingHead and ProjectManager who are also instance of User
4.Finally there is a Project class containing project details
Legend of classes used
User
Project
ProjectResource
Table Diagram
ProjectResource
ResourceId
ProjectId
UserId
ReportingHead
ProjectManager
Class Diagram
ProjectResource
ResourceId : String / Guid
Project : Project
User : User
ReportingHead : User
ProjectManager : User
note:
All the user information is stored in the User table
All the Project information is stored in the project table
Here's the Problem
When the application requests for Resource In a Project operations below are followed
First Get the Records for the Project
Get the UserId , make the request(using Users DAL) to get the user instance
Get the ProjectId, make the request(using Projects DAL) to get the project information
Finally assign Users and Project to instance of ProjectResource
clearly you can see 3 Db Calls are made here for populating single ProjectResource but the concerns and who manages the objects are clearly defined. This is the way i have planned to , since there is also connection pooling available in Sql Server & ADO.net
There is also another way where all the details are retrieved in single hit using Table Inner Joins and then Populating.
Which way should i really be taking and Why?
Extras:
.NET 2.0,ASP.net 2.0,C#,Sql Server 2005,DB on same machine hosting application.
For best performance and scalability, you should minimize the number of round-trips to the DB. To prove that to yourself, just run some benchmarks; it becomes clear very quickly.
One approach to a single round-trip is to use joins. Another is to return multiple result sets. The latter can be helpful in eliminating possible duplicate data.

ASP.NET Entity Framework Guid

Using the Entity Framework that I generated. I have a Roles table created during the default system AspNetSqlRoleProvider security set-up.
In the Roles table, I have an ApplicationId uniqueidentifier column. Which has a guid populated in it, which doesn't change for my application.
I need to add a Role manually through my app using the entity framework. However, when creating my Roles object and setting Roles.ApplicationId. It expects a type of Guid. I have the ApplicationId in my web.config app settings. As it shouldn't change. But it is returned at string. I cannot type cast the value either to use in Roles.ApplicationId.
What can I do to use my current ApplicationId value when trying to create a new role manually using the EF?
You're going to have to convert to a Guid, but that's easy to do. The constructor takes a string value that's the GUID form (new Guid("..")), or I think there may be a Parse method too.
HTH.

Resources