Connexion to LocalDB

sblb 1,231 Reputation points
2021-06-03T10:06:29.013+00:00

Hi,
I try to an application blazor WASM and I try to create DB.

I've created in BlazorApp1.Shared.Models the class :

using System;
using System.Collections.Generic;
using System.Text;

namespace BlazorApp1.Shared.Models
{
class Developer
{
public int Id { get; set; }
public string ECR { get; set; }
public DateTime DateCrea { get; set; }
public string Atelier { get; set; }
public string Nom { get; set; }
public string PNC { get; set; }
}
}

I've created in BlazorApp1.Server.Data the class

using Microsoft.EntityFrameworkCore;
using BlazorApp1.Shared.Models;

>

namespace BlazorApp1.Server.Data
{
public class ApplicationDBContext : DbContext
{
public ApplicationDBContext(DbContextOptions<ApplicationDBContext> options) : base(options)
{
}
public DbSet<Developer> Developers { get; set; }
}
}

When I bluid I have the error :

CS0122 'Developer' est inaccessible en raison de son niveau de protection ; Project : BlazorApp1.server ; File : ApplicationDBContext

It does not recognize the Developer class in DbSet<Developer>.

Have you an idea about this issue?

Thanks in advance

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,577 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yiyi You - MSFT 521 Reputation points
    2021-06-04T02:06:02.49+00:00

    Hi,@sblb ,

    CS0122 'Developer' est inaccessible en raison de son niveau de protection ; Project : BlazorApp1.server ; File : ApplicationDBContext

    As your error said,'Developer' is inaccessible due to its level of protection,so you need to change the protection level of 'Developer'.Try to change class Developertopublic class Developer`.

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    YiyiYou


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.