Upgrade to blazor studio - failing inferring data

hi Guys,

we have a huge chunk of our application developed in Razen and have now upgraded to a pro licence in Blazor studio

i'm going through the setup where i have loaded blazor studio, accessed the application,

from here i have inferred the data connection to the localhost DB (windows auth)

which i need to do in order to uplift the security from Radzen to Blazor S multi-tenant

soo far the infer data and build of the application has resulted in a huge amount of errors such as;

C:\Projects\TMRGovernance\client\Pages\AssuranceTemplatesScoringBand.razor.designer.cs(57,19): error CS0246: The type or namespace name 'TmrRadzenService' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\TMRGovernance\client\TmrGovernance.Client.csproj]
C:\Projects\TMRGovernance\client\Services\TmrRadzenService.cs(960,244): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'APIServices' (are you missing an assembly reference?) [C:\Projects\TMRGovernance\client\TmrGovernance.Client.csproj]

it looks like every page and every program within the project is impacted.

so, how do you go about uplifting an existing radzen program to blazor studio ?

okay so at a glance it looked like Blazor Studio was building assets into another solution project.... very strange;

i GIT discarded all the changes (some 350+ changes) and the application successfully compiled and launched.

i'll see if i can figure out a pattern here, but i suspect... when the solution includes additional projects, there is a possibility, assets out of blazore studio could be built in the first one.... no proof yet, just a guess

okay so i have a consistent pattern...
in this solution in blazor studio, when i go to Infer DB (i can connect and see tables, etc)
for some reason the assets are being built in another project within the solution

this project is a standard .NET API project which has a generated UI... i'm not sure if that has anything to do with it.

but at the moment, if i attempt to connect the database and infer it from Blazor Studio, assets don't appear to be generated in the correct project

looking at changes from the infer data action in GIT, it looks like this is the culprit


which is then getting propogated through the build

so the question is, why has this come in and why would it be pointing at the other project when it has worked perfectly in Radzen since we started using it???

Hi @TMRGlobal,

Unfortunately we can't tell why this has happened as we lack the full context - for example we have no idea what ApiServices or TmrGovernance are. Is it the name of the data source? Did you change it during infer?

Radzen Blazor Studio uses the name of the data source to generate the namespace for the models, services and data contexts. There are also settings that affect the naming conventions - how to generate the names of classes and properties from the database.

TMR Governance is the solution

the datasource is localhost \ TMRRadzen, that remains unchanged

the overall solution has 15 additional projects in it .. APIServices is one of those projects.... it's just a standard .net API project (the solution has 17 projects in total when counting the client and server CSPROJ)

oh and process wise....

i have simply opened blazor studio, opened the TMRGovernance solution and hit run.... it ran out of the box, but there is no auth working (it was previously in Radzen)
so i went to data in blazor S. attempted to infer... it was able to connect to the DB and read, however for some reason it's building assets in a different project.....

Radzen has never had this issue and works perfectly

Radzen Blazor Studio just builds your project and won't affect the existing authentication in any way. Make sure the right project is set as startup.

Radzen does a lot less things and never used the code from your other projects.

I don't know what this means.

In any case if you think you have bought a subscription for the wrong product let us know and we can issue a refund.

hey Korchev,

so if i run the project as is from the existing radzen build and configuration, the application launches (quicker than in radzen by the way, so nice performance improvement)

i can see a couple of problems though.

  1. when i click on 'data' i can't see the existing data source (which is called TMRRadzen) so when i then click create New and setup the local host, etc. all the code generation, creation of the controllers, etc takes place in the APIServices.CSPROJ project and not in the Server.CSPROJ project
  2. this is only happening in blazor studio
  3. I created a sample project in blazor studio and inferred the database perfectly
  4. i added security to that project without any issues.

i don't want to give up on blazor studio but we can't rebuild the application from scrach.

i also confirmed the startup project is the SERVER, which matches the new sample setup i put together

best case scenario, we are able to dig a little deeper and figure this out...

worst case scenario we swap the licence over for a Radzen one...

I would like to remind you again that we don't know anything about your solution. It seems that Radzen Blazor Studio picks the wrong project for the "server". At the moment it picks the first project from the solution that has Microsoft.NET.Sdk.Web in the Sdk attribute of the <Project> element. You probably have more than one that match this. You can try editing the .sln file and moving the Server.csproj file on top.

This is self-explanatory I guess. Radzen Blazor Studio infers the code while Radzen Studio works from the JSON files only.

okay so here is a further test and i think i have a pattern here.

in the sample project i added a data source (same DB as my main project) THEN i added security... all okay...

THEN i added a API project to the solution and BINGO, Blazor studio can't find the datasource....

so there is a fault or failure in the blazor studio for c# WA blazor solutions which have a .NET API project also in the solution... OR the solution includes additional projects... (not yet tested)....

but yeah @korchev can you see if you can replicate?

i have checked the old project solution .sln file and can confirm the server and client are the first two projects in the solution. i suspect your above comment where Radzen is selecting first with Microsoft.NET.Sdk.Web might actually be selecting by alphabetical order rather than programatic order.....???

I don't know what API project is.

Did you try this from my suggestion?

so @korchev if you create a new solution in blazorS. (add data and security,etc)
then in Visual Studio, you add an API project to that solution,

THEN, go back and try to interpret data, you will notice you have lost your existing data connection and if you create a new connection, the Models, etc from the generation are built in the API project, not in the server project....

basically this completley breaks BlazorS. ability to deal with data....

I see now. Would you mind answering my question - does it work if you change the order of the projects in the .sln file? Radzen Blazor Studio picks the first one that matches.

no, the Server and Client projects are at the top of the .SLN file

this does not appear to be the problem

I am not sure which project RBS should pick in this case. Here is how it currently determines it:

        public static bool IsServerProject(Project project)
        {
            var csproj = File.ReadAllText(project.FilePath);

            return IsServerProject(csproj);
        }

        private static bool IsServerProject(string csproj)
        {
            return csproj.Contains("Microsoft.NET.Sdk.Web");
        }

        public Project GetServerProject()
        {
            return Solution?.Projects.FirstOrDefault(IsServerProject);
        }

Here Solution is a Microsoft.CodeAnalysis.Solution instance.

yeah okay that's got a possibility to go wrong if >1 csproj with Microsoft.NET.SDK.Web in it..... you should have something more definitive such as .... includes Radzen.dll && name = server

Is using second solution for Radzen Blazor Studio which contains only one server project an option? For example create the solution from RBS and use a new one which contains all other projects. Probably the API project isn't needed to build the Blazor application.

the API solution uses the Radzen data models, it's a fairly big integrated solution

You can have a solution with all projects for use in Visual Studio. And keep one smaller for Radzen Blazor Studio.

1 Like