existing database using with web api 2 default test project - asp.net-web-api

I have created database with following tables
I'm trying to use this table structure with default test project in web api 2.
Once I run this through POSTMAN rest client , I'm getting following exception
is this possible to do, can I use existing identity table structure that mapped relationships with other tables

Related

How to access custom schema using `createBrowserSupabaseClient`?

I want to create a supabase client for a schema called 'schooldata' using the createBrowserSupabaseClient and can't find any documentation on how to do it.

Two seperate laravel projects sharing same login authentication

I have two Laravel projects in which one is a primary project and other is secondary just like some plugin of the primary project.
But I just want include one link of the secondary project in the primary one but it should have authentication of the first one i.e. primary.
One authentication for both laravel projects on a same server.
Any idea...
You can create a API for your authentication.
Create a REST full webservice and both your project will authenticate with this service.

Odata & Entity Framework, Many to Many relationship won't update

I'm writing an OData / Entity Framework client server app, and can't get Many to Many relationships to update from the client to the server.
The OData server is written using VS2013 in c# using WCF 5.6, and Entity Framework 6.
The database is simply 3 tables, Users, Permissions and a joining table UsersPermissions.
I'm using Entity Framework 6, which abstracts away the joining UsersPermissions table, leaving just the Users and Permissions entities.
From a User I can query their permissions no problem from a client using LINQ. Similarly I can query Users from Permissions, so the many to many relationship is good for reading from.
If I try to create a relationship from the client, say adding a new permission for a user, nothing happens. No traffic to the server, no data is changed in the joining table in the database.
This is the same whether I try to add a permission to a user in my client application, or if I use LinqPad to execute the query against my OData source.
The LINQ I'm using (taken from LinqPad) is:
// Get permission
var Permission = (from p in Permissions
where p.PermissionId == 1
select p).SingleOrDefault();
// Get user
var User = (from u in Users
where u.UserId == 1
select u).SingleOrDefault();
// Add permission to user
User.Permissions.Add(Permission);
SaveChanges();
I have tried creating a completely separate OData server application, and get the same problem.
If I execute the above LINQ within the OData server app, it executes as expected and the entry is added to UsersPermissions.
So it seems that the problem only exists when trying to update a many to many relationship from an OData client?
There is mention at the end of this article that OData has a bug in refreshing many to many relationships, but I can't even create one! http://msdn.microsoft.com/en-us/library/vstudio/bb896317(v=vs.100).aspx
I'd appreciate any help or suggestions towards tracking down why I cant create a many to many relationship from an OData client against an OData server using EF6.0.
To add a relationship between user and permission on client side, Please use DataServiceContext.AddLink
dsc.AddLink(User, "Permissions", Permission)
dsc.SaveChanges()

MVC Multi Tennat Application how to add sub site

I have an intranet application for which the URL is as follows
http:\\ServerName]\RunLog\
I am adding another department/tenant/group of users which will utilize the same instance of the application and same database. Their data will be different from the existing users. I am planning to add new column foreign key in each table to identify the specific tenant. I authenticate users windows authentication. I am thinking that the access to the application will be as follows
http:\[ServerName]\Platform1\RunLog
http:\[ServerName]\Platform2\RunLog
So for the above URL, how could I go about achieving that in the Application? I know how to make the table changes in SQL server, Updating the Entities, Updating the linq code in the controllers to pull up respective tennant data. Any help to get me started would be appriciated.
Kindly note that as you have given in your post, it is possible to identify the tenant's based on their URL. The table that contains the tenant details will also contain their url. So you will identify the tenant based on the URL. After identifying the tenant, we can authenticate the user's using the found tenant id / tenant code, get the tenant's configuration or settings using the same tenant id / tenant code.
I hope that you could have all the other entities of the application with a column called as TenantId. This will help you to fetch the data based on tenant. Your only change will be in the data access layer where you will filter the data that you retrieve from the Database.
Let me know if you have any other clarifications regarding the other specifics of this implementation.

User authentication using Entity Framework in ASP.NET MVC 3

I have an exisiting database which I used to create a Model usign the Database first approach. Please refer to the database diagram.
In my solution file, I have a Class Library of the model which has an ADO.NET connection to the database & and I a ASP.NET MVC 3 web application.
The funcitonality that I'm trying to get here is that - the information displayed once a user logs in is different for every user. How do I link the user login page to the 'user' table of the database? Is it directly using the connection string or do I need to go through the model that I created using the Database?
Add a field to your User table called "ProviderUserKey" or MembershipUserID, or something similar of type uniqueidentifier. You then call Membership.GetUser().ProviderUserKey and use that in your where clause of your User Table to select the correct User record based on the logged in user.

Resources