C
C#3mo ago
Zee

the namespace is not recognised

hey so I am making a wpf app that will be a flight booking app but I will be storing user data on an azure sql database I am trying to create a REST API and so far I have made a ASP.NetService named FakeFlightBookingAPI I made this class named ApplicationDbContext to interact with my database here and I am trying ref my Admin and Customer classes that are part of my WPF project not my ASP project and my code is below
using Microsoft.EntityFrameworkCore;
using FakeFlightBookingApp.Model;
namespace FakeFlightBookingAPI.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }


public DbSet<Admin> AdminUsers { get; set; }
public DbSet<Customer> RegularUsers { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using FakeFlightBookingApp.Model;
namespace FakeFlightBookingAPI.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }


public DbSet<Admin> AdminUsers { get; set; }
public DbSet<Customer> RegularUsers { get; set; }
}
}
my errrors are Severity Code Description Project File Line Suppression State Details Error CS0246 The type or namespace name 'FakeFlightBookingApp' could not be found (are you missing a using directive or an assembly reference?) FakeFlightBookingAPI D:\Zeeshan\Documents\FakeFlightBookingAPI\Data\ApplicationDbContext.cs 2 Active
Severity Code Description Project File Line Suppression State Details Error CS0246 The type or namespace name 'Customer' could not be found (are you missing a using directive or an assembly reference?) FakeFlightBookingAPI D:\Zeeshan\Documents\FakeFlightBookingAPI\Data\ApplicationDbContext.cs 11 Active
Severity Code Description Project File Line Suppression State Details Error CS0246 The type or namespace name 'Admin' could not be found (are you missing a using directive or an assembly reference?) FakeFlightBookingAPI D:\Zeeshan\Documents\FakeFlightBookingAPI\Data\ApplicationDbContext.cs 10 Active
No description
10 Replies
Zee
ZeeOP3mo ago
so yeah I cant seem to ref my customer and admin class long story short lol any idea whhy?
Zee
ZeeOP3mo ago
I did an add ref too
No description
Motley
Motley3mo ago
You have a warning in your dependencies
Motley
Motley3mo ago
No description
Zee
ZeeOP3mo ago
Severity Code Description Project File Line Suppression State Details Warning NETSDK1137 It is no longer necessary to use the Microsoft.NET.Sdk.WindowsDesktop SDK. Consider changing the Sdk attribute of the root Project element to 'Microsoft.NET.Sdk'. FakeFlightBookingApp C:\Program Files\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets 148 and it took me here
<Target Name="_CheckForUnnecessaryWindowsDesktopSDK"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0')) and '$(_MicrosoftWindowsDesktopSdkImported)' == 'true' and '$(TargetFrameworks)' == ''">
<NETSdkWarning ResourceName="UnnecessaryWindowsDesktopSDK" />
</Target>
<Target Name="_CheckForUnnecessaryWindowsDesktopSDK"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0')) and '$(_MicrosoftWindowsDesktopSdkImported)' == 'true' and '$(TargetFrameworks)' == ''">
<NETSdkWarning ResourceName="UnnecessaryWindowsDesktopSDK" />
</Target>
Motley
Motley3mo ago
Why is the API referencing things from the app? I think you have that backwards. Move the models you need to use in your API project to the API project. Then make the App reference the API project. Although... Honestly, I'm not sure why you are having an issue doing what you did.
Zee
ZeeOP3mo ago
oh so my customer and admin class should be in my api project?
Motley
Motley3mo ago
Yup You should have your REST API standalone not depending on anything. Your application should be built on top of that.
Zee
ZeeOP3mo ago
ok thx
Motley
Motley3mo ago
So if both projects need access to something, you put it in the REST API project. Good Luck!
Want results from more Discord servers?
Add your server